validate method
Validates value and returns a ValidationResult.
Returns Valid if the value passes validation, or Invalid/InvalidAll if it fails.
Implementation
@override
ValidationResult<T?, E> validate(T? value) {
if (value == null) {
return const Valid(null);
}
final result = validator.validate(value);
return switch (result) {
Valid(:final value) => Valid(value),
Invalid(:final error) => Invalid(error),
InvalidAll(:final errors) => InvalidAll(errors),
};
}