emojiValidator static method

String? emojiValidator(
  1. String? value, [
  2. String? errorMessage
])

emojiValidator to validate whtner the provided value does not contain any emojis

validator: (value) => SimpleValidations.emojiValidator(value, [errorMessage]),

Implementation

static String? emojiValidator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.emojiRegex;

  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter text without emojis';
  }
  return null;
}