IntegerValidator class

A validator that ensures a given double value is an integer.

The IntegerValidator checks if the provided value is a whole number (i.e., it has no decimal part). If the value is an integer, validation passes (null is returned). Otherwise, it returns the provided error message.

Example

final validator = IntegerValidator(message: 'The number must be an integer');

print(validator.validate(10.0)); // null (valid)
print(validator.validate(-5.0)); // null (valid)
print(validator.validate(3.14)); // 'The number must be an integer' (invalid)
print(validator.validate(null)); // 'The number must be an integer' (invalid)
Inheritance

Constructors

IntegerValidator.new({required String message})
Creates an IntegerValidator 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 double value) String?
Validates the provided value.
override

Operators

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