custom
custom(callback, [ctx])
Effect
Declare a custom restrict by a custom callback
function.
Arguments
callback
(Function) - The custom function for restricting.callback
has a parameter: the detected value. If validate failed, the callback should throw an error, otherwise, it means validation passed.[ctx]
(*) - The execution context ofcallback
.
NOTE
Since 1.3.0,
callback
can return a non-empty string to respect that validating failed, the string means the failure reason. Otherwise, it means validating passed if you return other values.
Example
Last updated