isValid method

  1. @override
bool isValid(
  1. dynamic value
)
override

Implementation

@override
bool isValid(dynamic value) {
  if (value is! String) {
    return false;
  }

  if (value.length > _length && _length != 0) {
    return false;
  }

  if (_allowList.isNotEmpty) {
    bool valid = true;
    value.split('').forEach((element) {
      if (!_allowList.contains(element)) {
        valid = false;
      }
    });
    return valid;
  }

  return true;
}