@Test public void testPropertyStateFailedValidation() { when(fieldStateValidator.validate(any(FormField.class))).thenReturn(false); assertFalse(formValidator.validate(valueField, model)); assertFalse(formValidator.validate(nameField, model)); assertFalse(formValidator.validate(lastNameField, model)); }
@Override public boolean validate(Form form, Object model) { form.getFields().forEach(FormField::clearError); boolean isModelValid = modelValidator.validate(form.getFields(), model); boolean isFieldStateValid = fieldStateValidator.validate(form.getFields()); return isFieldStateValid && isModelValid; }
FormValidatorImpl implements FormValidator { @Override public boolean validate(Form form, Object model) { form.getFields().forEach(FormField::clearError); boolean isModelValid = modelValidator.validate(form.getFields(), model); boolean isFieldStateValid = fieldStateValidator.validate(form.getFields()); return isFieldStateValid && isModelValid; } }
FormValidatorImpl implements FormValidator { @Override public boolean validate(Form form, Object model) { form.getFields().forEach(FormField::clearError); boolean isModelValid = modelValidator.validate(form.getFields(), model); boolean isFieldStateValid = fieldStateValidator.validate(form.getFields()); return isFieldStateValid && isModelValid; } @Inject  FormValidatorImpl(ModelValidator modelValidator,
                             FieldStateValidator fieldStateValidator); }
FormValidatorImpl implements FormValidator { @Override public boolean validate(Form form, Object model) { form.getFields().forEach(FormField::clearError); boolean isModelValid = modelValidator.validate(form.getFields(), model); boolean isFieldStateValid = fieldStateValidator.validate(form.getFields()); return isFieldStateValid && isModelValid; } @Inject  FormValidatorImpl(ModelValidator modelValidator,
                             FieldStateValidator fieldStateValidator); @Override boolean validate(Form form, Object model); @Override boolean validate(FormField formField,
                            Object model); ModelValidator getModelValidator(); void setModelValidator(ModelValidator modelValidator); }
FormValidatorImpl implements FormValidator { @Override public boolean validate(Form form, Object model) { form.getFields().forEach(FormField::clearError); boolean isModelValid = modelValidator.validate(form.getFields(), model); boolean isFieldStateValid = fieldStateValidator.validate(form.getFields()); return isFieldStateValid && isModelValid; } @Inject  FormValidatorImpl(ModelValidator modelValidator,
                             FieldStateValidator fieldStateValidator); @Override boolean validate(Form form, Object model); @Override boolean validate(FormField formField,
                            Object model); ModelValidator getModelValidator(); void setModelValidator(ModelValidator modelValidator);  }