Time
Validate time strings in HH:mm or HH:mm:ss format
Time
The time rule validates that a value is a valid 24-hour time string: HH:mm or HH:mm:ss.
Configuration
| Config flag | Type | Description |
|---|---|---|
time | boolean | Requires a valid time string. |
validationSchema: {
startTime: { time: true },
}With a custom message:
startTime: { time: "Enter a valid time" }V builder
import { V } from "formify-js";
V.time()
V.time("Enter a valid time")Default message
Must be a valid time
Examples
| Value | Result |
|---|---|
14:30 | ✅ Valid |
09:15:45 | ✅ Valid |
25:00 | ❌ Invalid (hour out of range) |
14:75 | ❌ Invalid (minute out of range) |
Things to know
- Hour and minute ranges are checked: hours 00–23, minutes/seconds 00–59.
- The seconds part is optional.
- Empty values pass unless
required: trueis also set.