negative method
Checks if the value is negative
message
is the message to return if the validation fails
Implementation
EzValidator<T> negative([String? message]) => addValidation((v, [_]) {
if (v is num) {
return v > 0
? message ?? EzValidator.globalLocale.negative('$v', label)
: null;
}
if (v is String) {
return num.tryParse(v) != null && num.parse(v) > 0
? message ?? EzValidator.globalLocale.negative('$v', label)
: null;
}
return 'Invalid type for min comparison';
});