@Test public void shouldRejectIfFieldIsNull() { RequiredFieldValidator fieldValidator = new RequiredFieldValidator("name", null); List<String> errors = new ArrayList<>(); fieldValidator.validate(new StartupForm(), errors, ConfigSource.UI); assertTrue(errors.contains(String.format(RequiredFieldValidator.ERROR_REQUIRED, "name"))); }
@Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (StringUtils.isBlank(fieldValue)) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, fieldName)); } } }
RequiredFieldValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (StringUtils.isBlank(fieldValue)) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, fieldName)); } } } }
RequiredFieldValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (StringUtils.isBlank(fieldValue)) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, fieldName)); } } } RequiredFieldValidator(String fieldName, String fieldValue); }
RequiredFieldValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (StringUtils.isBlank(fieldValue)) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, fieldName)); } } } RequiredFieldValidator(String fieldName, String fieldValue); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource); @Override boolean equals(Object o); @Override int hashCode(); }
RequiredFieldValidator implements AbstractValidator { @Override public void validate(StartupForm target, List<String> errors, ConfigSource configSource) { if (StringUtils.isBlank(fieldValue)) { if (!configSource.isFile()) { errors.add(String.format(ERROR_REQUIRED, fieldName)); } } } RequiredFieldValidator(String fieldName, String fieldValue); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource); @Override boolean equals(Object o); @Override int hashCode(); static final String ERROR_REQUIRED; }