[ColdBox 3.8.1] Wirebox validation method value

I have been exploring the Wirebox validation and making custom validation methods. I created a function using the recommended setup “The name of a method to call in the target object for validation. The function must return boolean and accepts two parameters: value and target.”
I did not find documentation as to what these params are, what they are linked to, or how they get passed into the function. I made some assumptions and got it to work. However, I am confused as to why the function must take in the target AND the value, when anytime I reference the arguments.value I get an error, and the function executes perfectly when I remove the parameter.

What is the “value” parameter?

Here is the code I am running:

property name=“id”;

property name=“firstname”;
property name=“lastName”;
property name=“email”;
property name=“age”;

//validation
this.constraints = {
firstName = { required=true, requiredMessage=“you forgot the name”},
lastName = { method=“checkLastName” },
email = { required=true, type=“email” },
age = { required=true, type=“integer” }
};

function init() {
return this;
}

function checkLastName( Any target ) {
if( arguments.target NEQ “foo” ) {
return false;
}
return true;
}

I think the docs are out of date on this? It appears that the signature changed from 3.5.3 to 3.8:

3.5.3 - MethodValidator.cfc

if( evaluate(“arguments.target.#arguments.validationData#( arguments.targetValue, arguments.target )”) ){
return true;
}

3.8 - MethodValidator.cfc

Well, in fairness, the docs do say they cover up to 3.7.0 :slight_smile:

Cool thanks! Where did you find that information? "3.5.3 - MethodValidator.cfc

if( evaluate(“arguments.target.#arguments.validationData#( arguments.targetValue, arguments.target )”) ){
return true;
}

3.8 - MethodValidator.cfc

Hi Joseph–

I just browsed the source code:

https://github.com/ColdBox/coldbox-platform/blob/3.5.3/system/validation/validators/MethodValidator.cfc

https://github.com/ColdBox/coldbox-platform/blob/3.8.0/system/validation/validators/MethodValidator.cfc

Cool, thanks! Always learning something!

Sure thing, glad it was helpful!