Date
Validate date strings — ISO format or any parseable date
Date
The date rule validates that a value is a valid date string — either ISO format (YYYY-MM-DD) or any string Date can parse.
Configuration
| Config flag | Type | Description |
|---|---|---|
date | boolean | Requires a valid date string. |
validationSchema: {
birthday: { date: true },
}With a custom message:
birthday: { date: "Enter a valid date" }V builder
import { V } from "formify-js";
V.date()
V.date("Enter a valid date")Default message
Must be a valid date
Examples
| Value | Result |
|---|---|
2024-01-15 | ✅ Valid |
01/15/2024 | ✅ Valid |
hello | ❌ Invalid |
2024-13-40 | ❌ Invalid (month/day out of range) |
Things to know
- The check is calendar-aware:
2024-02-30fails because February never has 30 days. - If you need a specific fixed format, enforce it with the
patternvalidator instead. - Empty values pass unless
required: trueis also set.