@Test public void invalidBase64() { final String value = UUID.randomUUID().toString(); assertThat(validator.isValid(value, constraintValidatorContext)).isFalse(); }
@Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } }
Base64Validator implements ConstraintValidator<ValidBase64, String> { @Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } } }
Base64Validator implements ConstraintValidator<ValidBase64, String> { @Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } }  }
Base64Validator implements ConstraintValidator<ValidBase64, String> { @Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } }  @Override boolean isValid(String value, ConstraintValidatorContext cvc); }
Base64Validator implements ConstraintValidator<ValidBase64, String> { @Override public boolean isValid(String value, ConstraintValidatorContext cvc) { if(Objects.isNull(value)) { return true; } if(value.startsWith(NACL_FAILURE_TOKEN)) { return true; } try { Base64.getDecoder().decode(value); return true; } catch (IllegalArgumentException ex) { return false; } }  @Override boolean isValid(String value, ConstraintValidatorContext cvc);  }