EvenValidator class

A validator that ensures a given int value is even.

The EvenValidator checks if the provided value is an even number (i.e., divisible by 2 without a remainder). If the value is even, validation passes (null is returned). Otherwise, it returns the provided error message.

Example

final validator = EvenValidator(message: 'The number must be even');

print(validator.validate(10)); // null (valid)
print(validator.validate(-4)); // null (valid)
print(validator.validate(3)); // 'The number must be even' (invalid)
print(validator.validate(null)); // 'The number must be even' (invalid)
Inheritance

Constructors

EvenValidator.new({required String message})
Creates an EvenValidator with a required error message.

Properties

hashCode int
The hash code for this object.
no setterinherited
message String
The error message to be returned when validation fails.
finalinherited
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
validate(covariant int value) String?
Validates the provided value.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited