getValidator function Null safety

bool getValidator(
  1. EQUFormValidatorType type,
  2. dynamic input
)

Implementation

bool getValidator(EQUFormValidatorType type, input) {
  RegExp exp;
  switch (type) {
    case EQUFormValidatorType.MAINLAND_PHONE:
      exp = RegExp(r'^(\+?0?86\-?)?1[3456789]\d{9}$');
      break;
    case EQUFormValidatorType.PHONE:
      exp = RegExp(
          r'^(\d{11})$|^((\d{7,8})|(\d{4}|\d{3})(\d{7,8})|(\d{4}|\d{3})(\d{7,8})(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})(\d{4}|\d{3}|\d{2}|\d{1}))$');
      break;
    case EQUFormValidatorType.NAME:
      exp = RegExp(r'^[a-zA-Z0-9\u4e00-\u9fa5]{2,32}$');
      break;
    case EQUFormValidatorType.AGE:
      exp = RegExp(r'^(?:[1-9][0-9]?|1[0-9][0-9]|200)$');
      break;
    case EQUFormValidatorType.PRICE:
      exp = RegExp(r'^([1-9]\d{0,5}|0)([.]?|(\.\d{1,2})?)$');
      break;
    case EQUFormValidatorType.NUMBER:
      exp = RegExp(r'^(-?[1-9][0-9]*|0)([.]?|(\.\d+)?)$');
      break;
  }
  return exp.hasMatch(input ?? '');
}