fastest-validator icon indicating copy to clipboard operation
fastest-validator copied to clipboard

improving the custom function with arrays of elements

Open FerX opened this issue 2 years ago • 2 comments

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!

FerX avatar Jul 14 '23 06:07 FerX

@icebob I have added documentation. It is ready for your evaluation. thanks.

FerX avatar Jun 13 '24 16:06 FerX

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

FerX avatar Jun 14 '24 15:06 FerX

Great job, thanks!

icebob avatar Jul 28 '24 10:07 icebob