fastest-validator
fastest-validator copied to clipboard
improving the custom function with arrays of elements
I have enhanced the custom handling functionality to accommodate the reception of an array containing anonymous functions or function names defined in the global custom functions.
please refer to the detailed description provided in issue #328.
I require assistance in updating the documentation!
@icebob I have added documentation. It is ready for your evaluation. thanks.
@icebob I also added the use of shorthands and parameters
example:
const schema = {
people:{
type: "number",
custom: [
"compare|gte:-100|lt:200", // short definition with additional parameters - equal to: {type:"compare",gte:-100, lt:200},
"even",
"real",
function (value, errors){
if(value === "3" ){
errors.push({ type: "notPermitNumber", actual: value });
}
return value;
}
]
}
};
Great job, thanks!