DateMessage class
A message container for validation errors related to date values.
The DateMessage
class provides predefined error messages for date-based
validations, such as checking if a date is before or after another date,
falls within a range, or occurs on a weekday or weekend.
Example
final dateMessage = DateMessage(
after: 'The date must be after the given date',
before: 'The date must be before the given date',
betweenDates: (min, max) => 'The date must be between ${min.toIso8601String()} and ${max.toIso8601String()}',
weekday: 'The date must be a weekday',
weekend: 'The date must be a weekend',
);
print(dateMessage.after); // 'The date must be after the given date'
print(dateMessage.before); // 'The date must be before the given date'
print(dateMessage.betweenDates(DateTime(2025, 1, 1), DateTime(2025, 12, 31)));
// 'The date must be between 2025-01-01T00:00:00.000 and 2025-12-31T00:00:00.000'
- Inheritance
-
- Object
- BaseMessage
- DateMessage
Constructors
Properties
- after → String
-
The error message displayed when a date must be after a specific date.
final
- any → String
-
The error message used when at least one of multiple validators must pass (
or
condition).finalinherited - array → ArrayMessage
-
The error message container for array-related validation errors.
finalinherited
- before → String
-
The error message displayed when a date must be before a specific date.
final
- betweenDates → String Function(DateTime min, DateTime max)
-
The error message displayed when a date must be between two specific dates.
final
- every → String
-
The error message used when all of multiple validators must pass (
and
condition).finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- refine → String
-
The error message used when a custom refinement validation fails.
finalinherited
- required → String
-
The error message used when a required value is missing.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- weekday → String
-
The error message displayed when a date must be on a weekday (Monday-Friday).
final
- weekend → String
-
The error message displayed when a date must be on a weekend (Saturday-Sunday).
final
Methods
-
copyWith(
{String? after, String? any, String? before, String betweenDates(DateTime min, DateTime max)?, String? every, String? refine, String? required, ArrayMessage? array, String? weekday, String? weekend}) → DateMessage -
Creates a copy of the current
DateMessage
instance with updated values.override -
mergeWithBase(
BaseMessage base) → DateMessage -
Merges the current
DateMessage
instance with aBaseMessage
, replacing only the undefined values with those from the base. -
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