if
Learn about the available options, methods and use cases.
Usage
import e from "validator";
await e.if(
(value) => !isNaN(value),
{} // Pass optional options...
)
.validate("10") // returns "10"Options
interface IIfValidatorOptions extends TBaseValidatorOptions {
/** Pass custom messages for the errors */
messages?: Partial<Record<"typeError", TErrorMessage>>;
}Examples
Case 1 (Basic usage)
Last updated