Factory class for creating DateTime validation rules.
All rules are generic over the error type E, so you can use
String, enum, sealed classes, or any custom error type.
Example
final birthDateValidator = Validate.all<DateTime, String>([
DateRules.past(error: 'Birth date must be in the past'),
DateRules.age(18, 120, error: 'Must be 18-120 years old'),
]);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
after<
E> (DateTime date, {required E error}) → Rule< DateTime, E> -
Validates that the date is after
date. -
age<
E> (int minAge, int maxAge, {required E error}) → Rule< DateTime, E> - Validates that the person's age (based on birth date) is within range.
-
before<
E> (DateTime date, {required E error}) → Rule< DateTime, E> -
Validates that the date is before
date. -
businessDay<
E> ({required E error}) → Rule< DateTime, E> - Validates that the date is a business day (Monday-Friday).
-
future<
E> ({required E error}) → Rule< DateTime, E> - Validates that the date is in the future (after now).
-
past<
E> ({required E error}) → Rule< DateTime, E> - Validates that the date is in the past (before now).
-
range<
E> (DateTime start, DateTime end, {required E error}) → Rule< DateTime, E> -
Validates that the date is within
startandend(inclusive). -
sameDay<
E> (DateTime date, {required E error}) → Rule< DateTime, E> -
Validates that the date is on the same day as
date. -
weekday<
E> (List< int> days, {required E error}) → Rule<DateTime, E> - Validates that the date falls on specific weekdays.