@Test public void atLeastTest() { StringLengthValidator s = StringLengthValidator.atLeast(5, "test"); Assert.assertTrue(s.validate("gosjrgohgsr").getResult()); Assert.assertFalse(s.validate(" ").getResult()); Assert.assertFalse(s.validate("ae").getResult()); Assert.assertTrue(s.validate("¶æ¢¶ππ§±#").getResult()); try { StringLengthValidator s2 = StringLengthValidator.atLeast(-10, "test"); fail(); } catch (IllegalArgumentException ignored) {} try { StringLengthValidator s3 = StringLengthValidator.atLeast(0, "test"); } catch (IllegalArgumentException e) { fail(); } }
public static StringLengthValidator atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new StringLengthValidator(min, Integer.MAX_VALUE, errorMessage); }
StringLengthValidator extends CustomValidator<String> { public static StringLengthValidator atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new StringLengthValidator(min, Integer.MAX_VALUE, errorMessage); } }
StringLengthValidator extends CustomValidator<String> { public static StringLengthValidator atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new StringLengthValidator(min, Integer.MAX_VALUE, errorMessage); } private  StringLengthValidator(int min, int max, String errorMessage); }
StringLengthValidator extends CustomValidator<String> { public static StringLengthValidator atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new StringLengthValidator(min, Integer.MAX_VALUE, errorMessage); } private  StringLengthValidator(int min, int max, String errorMessage); static StringLengthValidator between(int min, int max, String errorMessage); static StringLengthValidator atLeast(int min, String errorMessage); static StringLengthValidator upTo(int max, String errorMessage); static StringLengthValidator exactly(int value, String errorMessage); }
StringLengthValidator extends CustomValidator<String> { public static StringLengthValidator atLeast(int min, String errorMessage) { if (min < 0) { throw new IllegalArgumentException("Minimum string length cannot be negative."); } return new StringLengthValidator(min, Integer.MAX_VALUE, errorMessage); } private  StringLengthValidator(int min, int max, String errorMessage); static StringLengthValidator between(int min, int max, String errorMessage); static StringLengthValidator atLeast(int min, String errorMessage); static StringLengthValidator upTo(int max, String errorMessage); static StringLengthValidator exactly(int value, String errorMessage);  }