You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@icebob
I am working on a pull request that can execute code like this, before implementing the tests I wanted to know if you like it
letValidator=require("../index");letv=newValidator({debug: true,useNewCustomCheckerFunction: true,messages: {// Register our new error message textevenNumber: "The '{field}' field must be an even number! Actual: {actual}",realNumber: "The '{field}' field must be a real number! Actual: {actual}",notPermitNumber: "The '{field}' cannot have the value {actual}",},customFunctions:{even: (value,errors)=>{if(value%2!=0){errors.push({type: "evenNumber",actual: value});}returnvalue;},real: (value,errors)=>{if(value<0){errors.push({type: "realNumber",actual: value});}returnvalue;}}});constschema={people:{type: "number",custom: ["even","real",function(value,errors){if(value==="3"){errors.push({type: "notPermitNumber",actual: value});}returnvalue;}]}};console.log(v.validate({people:5},schema));console.log(v.validate({people:-5},schema));console.log(v.validate({people:3},schema));
I suggest adding support for an array of functions in the custom property of Fastest Validator.
This enhancement would enable users to apply multiple filters efficiently, simplifying complex validation scenarios and enhancing code readability.
example:
The text was updated successfully, but these errors were encountered: