Skip to content

Type Alias: CustomValidator<V, R> ​

CustomValidator<V, R> = (value, helpers) => R | ErrorReport

A custom validation rule given to custom(). It receives the value (converted by the previous rules) and the helpers of the validation, and returns the value to keep (a new one replaces it; undefined keeps it unchanged), or the error returned by helpers.error(code, context) or helpers.message(messages). An error it throws fails the validation with the code any.custom and the error message.

Type Parameters ​

V ​

V = any

R ​

R = V

Parameters ​

value ​

V

helpers ​

CustomHelpers<R>

Returns ​

R | ErrorReport

Released under the MIT License.