isValid function

bool isValid(
  1. String value, {
  2. int minLength = 0,
  3. RegExp? regex,
})

Implementation

bool isValid(String value, {int minLength = 0, RegExp? regex}) {
  if (value.isEmpty || value.length < minLength) {
    return false;
  }
  if (regex != null && !regex.hasMatch(value)) {
    return false;
  }
  return true;
}