Examples
- Basic Validation
- Form Integration
Methods
NeoDateValidator.validate()
Parses a DD-MM-YYYY string and throws when it is not a real date.Parameters
String
required
The date string to validate in DD-MM-YYYY format.
Return Value
DateTime
The parsed DateTime if the string is valid.
Exceptions
FormatException
Thrown with specific error messages for invalid formats, incomplete segments, or invalid dates (e.g., “Day 30 is not valid for February 2023”).
NeoDateValidator.validateIsBefore()
Validates that a date occurs before another specified date.Parameters
DateTime
required
The date to validate.
DateTime
required
The date that
date must be before.Exceptions
ArgumentError
Thrown if the date is not before the specified date.
NeoDateValidator.validateIsAfter()
Validates that a date occurs after another specified date.Parameters
DateTime
required
The date to validate.
DateTime
required
The date that
date must be after.Exceptions
ArgumentError
Thrown if the date is not after the specified date.
NeoDateValidator.validateIsInRange()
Validates that a date falls within a specified range (inclusive).Parameters
DateTime
required
The date to validate.
DateTime
required
The start of the valid range (inclusive).
DateTime
required
The end of the valid range (inclusive).
Exceptions
ArgumentError
Thrown if the date is not within the specified range.
NeoDateValidator.validateIsNotFuture()
Validates that a date is not in the future (today or earlier).Parameters
DateTime
required
The date to validate.
Exceptions
ArgumentError
Thrown if the date is in the future.
NeoDateValidator.validateIsNotPast()
Validates that a date is not in the past (today or later).Parameters
DateTime
required
The date to validate.
Exceptions
ArgumentError
Thrown if the date is in the past.
Best Practices
- Catch
FormatExceptionandArgumentErrorseparately. - Call it from
onSubmittedonNeoDateField. The field’s value is thedateString.

