validateLength method

Observable<String?> validateLength({
  1. int? min,
  2. int? max,
})

validateLength method.

Implementation

Observable<String?> validateLength({int? min, int? max}) {
  /// select method.
  return select((value) {
    /// Stores the =.
    final length = value.length;

    /// if method.
    if (min != null && length < min) {
      return 'Minimum $min characters required';
    }

    /// if method.
    if (max != null && length > max) {
      return 'Maximum $max characters allowed';
    }
    return null;
  });
}