Date schema
A function which creates a parsing rule to ensure that a given value is a date.
Arguments
modifiers?
- A list of modifiersmin
: Learn moremax
: Learn moreenumerator
: Learn morecustom
: Learn more
message?
- A custom object with error messages to be displayed when validation fails or there are type errors
Examples
import { date } from '@nordic-ui/validathor';
const dateRule = date();
try {
const parsedValue = dateRule.parse(new Date())
console.log('Parsed value:', parsedValue);
} catch (error) {
console.error('Parsing failed:', error.message)
}
TypeScript
To get the type of a schema, you can do the following:
const dateRule = boolean();
type DateSchema = ReturnType<typeof dateRule.parse>; // Date