passes method

  1. @override
FutureOr<bool> passes(
  1. ValidationContext context
)
override

Validates the value using the given context.

Returns true if valid, otherwise false.

Implementation

@override
FutureOr<bool> passes(ValidationContext context) {
  final value = context.value;
  final args = context.parameters;
  final min = _min ?? num.tryParse(args.isNotEmpty ? args[0] : '') ?? 0;

  if (value == null) return true; // Null rules usually handled by 'required'

  if (value is num) {
    return value >= min;
  } else if (value is String) {
    // Check if string is numeric and we strictly want numeric comparison ??
    // Laravel heuristic: if 'numeric' rule is present, treat as number.
    // Here we assume String -> Length, unless it looks like a number?
    // Standard is: String -> Length. Numeric -> Value.
    // But if input is from HTTP form, it's always string.
    // Better approach: context.isNumeric?
    // For now, adhere to simple type check: String -> Length.
    // UNLESS the user explicitly casts it or we check 'numeric' rule presence (hard here).
    // Let's stick to standard behavior: String=length.
    return value.length >= min;
  } else if (value is Iterable || value is Map) {
    return value.length >= min;
  } else {
    return value.toString().length >= min;
  }
}