code: public static boolean validateRequiredField(String field, String reg) {
          return !(field == null || field.isEmpty()) && Pattern.matches(reg, field);
      }
docs: Validate the required field String against the regex.
  
  @param field
  the field value String.
  @param reg
  the regex.
  @return true if matched.