BetweenDatesValidator class

A validator that checks if a given DateTime falls within a specified date range.

Example

final validator = BetweenDatesValidator(
  min: DateTime(2025, 1, 1),
  max: DateTime(2025, 12, 31),
  message: 'The date must be between January 1, 2025, and December 31, 2025',
);

print(validator.validate(DateTime(2025, 6, 15))); // null (valid)
print(validator.validate(DateTime(2024, 12, 31))); // 'The date must be between...' (invalid)
Inheritance

Constructors

BetweenDatesValidator.new({required DateTime min, required DateTime max, required String message})
Creates a BetweenDatesValidator with a required date range and message.

Properties

hashCode int
The hash code for this object.
no setterinherited
max DateTime
The maximum allowed date (inclusive).
final
message String
The error message to be returned when validation fails.
finalinherited
min DateTime
The minimum allowed date (inclusive).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(covariant DateTime value) String?
Validates the provided value.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited