DecimalValidator class

A validator that ensures a given double value is a decimal (non-integer).

The DecimalValidator checks if a given double value is not a whole number. If the value has a fractional part, the validation passes (null is returned). Otherwise, it returns the provided error message.

Example

final validator = DecimalValidator(message: 'The number must be a decimal');

print(validator.validate(3.14)); // null (valid)
print(validator.validate(10.5)); // null (valid)
print(validator.validate(4.0));  // 'The number must be a decimal' (invalid)
print(validator.validate(null)); // 'The number must be a decimal' (invalid)
Inheritance

Constructors

DecimalValidator({required String message})
Creates a DecimalValidator 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