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;
}