date
Learn about the available options, methods and use cases.
Usage
Following is the simple usage of this validator
import e from "validator";
await e.date(
{} // Optionally pass options
)
.validate(new Date()) // returns new Date()Options
Following are the available options for this validator
interface IDateValidatorOptions extends TBaseValidatorOptions {
/** Pass custom messages for the errors */
messages?: Partial<
Record<"typeError" | "smaller" | "greater", TErrorMessage>
>;
/**
* Provide a start time for validation (Use .start or .between methods)
*/
startsAt?: Date | number;
/**
* Provide an ending time for validation (Use .end or .between methods)
*/
endsAt?: Date | number;
}Methods
Following are the available methods on this validator
Examples
Read the examples below to understand different use cases
Case 1 (Basic usage)
Case 2 (Date in range)
Last updated
Was this helpful?