Rod

Dates

Validating timestamp ranges.

Dates

The date validator primarily works with Unix timestamps (milliseconds).

use rod_rs::date;

// Date between Year 2000 and Year 2025
let schema = date().min(946684800000).max(1735689600000);
import { rod } from 'rod-js';

const schema = rod.date()
  .min(new Date("2000-01-01").getTime())
  .max(new Date("2025-01-01").getTime());
import rod

schema = rod.date().min(946684800000).max(1735689600000)

ISO Strings

If you are validating string-formatted dates (e.g., "2024-01-01T00:00:00Z"), use the string validator's datetime helper instead.

string().datetime()
rod.string().datetime()
rod.string().datetime()

On this page