Skip to main content

date-range

$date-range

Validates that a date value falls within the specified range (inclusive). Can specify minimum, maximum, or both bounds. Bounds are parsed using the same rules as the date schema normalizer, so strings, numbers, and Date objects are all accepted.

Parameters

  • min (optional): Minimum date (inclusive). If omitted, no lower bound.
  • max (optional): Maximum date (inclusive). If omitted, no upper bound.

Example

// Object form with named parameters
new Schema('date').validator({'$date-range': {min: '2024-01-01', max: '2024-12-31'}})

// Cross-reference: end date must be >= start date
new Schema('object')
.property('start', new Schema('date'))
.property('end', new Schema('date').validator({'$date-range': {min: {$reference: '^start'}}}))