@Test public void isValid() { LoginNameValidator validator = new LoginNameValidator(); assertTrue(validator.isValid(null, null)); assertTrue(validator.isValid(StringUtils.EMPTY, null)); assertTrue(validator.isValid("admin", null)); assertFalse(validator.isValid("x/y", null)); assertFalse(validator.isValid("x,y", null)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); }
LoginNameValidator implements ConstraintValidator<ValidLoginName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); } }
LoginNameValidator implements ConstraintValidator<ValidLoginName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); }  }
LoginNameValidator implements ConstraintValidator<ValidLoginName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); }  @Override void initialize(ValidLoginName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context); }
LoginNameValidator implements ConstraintValidator<ValidLoginName, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } return Pattern.matches("^" + DocumentrConstants.USER_LOGIN_NAME_PATTERN + "$", value); }  @Override void initialize(ValidLoginName annotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }