code: public static void validatePattern(String pattern, String string){
          if (!string.replaceAll(pattern, "").equals(string)){
              throw new RestrictionViolationException("Violation of pattern restriction, the string doesn't math the acceptable pattern, which is " + pattern);
          }
      }
docs: Validates if the received {@code string} matches the pattern.
  @param pattern The restriction pattern.
  @param string The {@link String} that should match the restriction pattern.