validate method
void
validate(
- String? newValue
)
override
Implementation
@override
void validate(String? newValue) {
final String? _newValue = newValue;
if (_newValue == null || _newValue.isEmpty) {
if (isRequired) {
throw RequiredValueException();
}else{
return;
}
}
final DateTime? valueLocal = DateTime.tryParse(_newValue);
if (valueLocal == null) {
throw InvalidValueException();
}
final DateTime? maxValueLocal = maxValue;
final DateTime? minValueLocal = minValue;
if (maxValueLocal == null && minValueLocal == null) {
return;
}
if (maxValueLocal != null) {
if (valueLocal.compareTo(maxValueLocal) <= 0) {
throw TooLongValueException();
}
}
if (minValueLocal != null) {
if (valueLocal.compareTo(minValueLocal) >= 0) {
throw TooShortValueException();
}
}
}