TextValidator { public static boolean isIdCard(@Nullable CharSequence input) { return isMatch(PATTERN_REGEX_ID_CARD15, input) || isMatch(PATTERN_REGEX_ID_CARD18, input); }  static boolean isMobileSimple(@Nullable CharSequence input); static boolean isMobileExact(@Nullable CharSequence input); static boolean isTel(@Nullable CharSequence input); static boolean isIdCard(@Nullable CharSequence input); static boolean isEmail(@Nullable CharSequence input); static boolean isUrl(@Nullable CharSequence input); static boolean isDate(@Nullable CharSequence input); static boolean isIp(@Nullable CharSequence input); static boolean isMatch(Pattern pattern, CharSequence input); static final String REGEX_MOBILE_EXACT; }
@Test public void isIdCard() { assertThat(TextValidator.isIdCard("440101198987754ab")).isFalse(); assertThat(TextValidator.isIdCard("440101198987754122")).isFalse(); assertThat(TextValidator.isIdCard("440101891232451")).isFalse(); assertThat(TextValidator.isIdCard("440101198909204518")).isTrue(); assertThat(TextValidator.isIdCard("440101891231451")).isTrue(); }