Search results

Types

Classes
Interfaces
Enums
Functions
Type aliases
Constants

Members

Properties
Methods
Getters
Setters
Enum members
Show privates

Other

In this module only

Function compile

<T>

Defined in index

(
schema: Schemainterface Schemacompiler/Schema,
...args: Arrayexternal Array<string>
): 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!"));