BeforeDateValidator class

A validator that checks if the value date is less than date.

The BeforeDateValidator can be used with FieldControllers holding values of type DateTime. It ensures that the value is less than date.

If the value is null, it is treated as valid by default.

Properties

  • date: The date the value must be strictly less than.
  • message: An optional custom error message to display when invalid.

Example

FieldController<DateTime> field = FieldController(
  key: 'date',
  validators: [BeforeDateValidator(DateTime(2025, 7, 12))],
);

// If field.value = DateTime(2025, 7, 13), validation fails.
// If field.value = DateTime(2025, 7, 12), validation fails.
// If field.value = DateTime(2025, 7, 11), validation passes.

See also

Inheritance

Constructors

BeforeDateValidator.new(DateTime date, {String? message})

Properties

date DateTime
The date the value must be strictly less than.
final
hashCode int
The hash code for this object.
no setterinherited
message String?
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(FieldController<DateTime> controller) ValidationResult
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onValidate(FieldController<DateTime> controller) ValidationResult
override
toString() String
A string representation of this object.
inherited

Operators

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