class ValidBase64Validator implements ConstraintValidator<ValidBase64, String> {

  @Override public boolean isValid(String value, ConstraintValidatorContext ctx) {
    try {
      if (value != null) {
        Base64.getDecoder().decode(value);
      }
    } catch (IllegalArgumentException ignored) {
      return false;
    }

    return true;
  }

}