Function compile
<T>
(): ValidatorFninterface ValidatorFncompiler/ValidatorFn<Ttype parameter T>
Creates a very fast validation function from the provided object. The values for the argument names get passed when calling the function.
· schema -
The object to make a validator for.
· args -
Custom argument names that the validation function will be able to access.
Example
const validator = compile({
value: { type: "number", errors: {
type: "() => someExternalFn()"
}}
}, "someExternalFn")
validator({...}, () => console.log("I'm getting called inside the validator!"));