negative static method

String? Function(String) negative({
  1. String message = 'Value must be negative.',
})

Validates that the input is a negative number.

Implementation

static String? Function(String) negative({
  String message = 'Value must be negative.',
}) {
  return (value) {
    if (value.trim().isEmpty) return null;
    final num = double.tryParse(value);
    if (num == null) return 'Please enter a valid number.';
    if (num >= 0) return message;
    return null;
  };
}