@Test public void isInvalidWithBlank() throws Exception { assertNotEmpty("is invalid with String", new NotBlankConstraint(BLANK, PROPERTY_NAME).validate()); assertNotEmpty("is invalid with EditText", new NotBlankConstraint(generateEditText(BLANK), PROPERTY_NAME).validate()); assertNotEmpty("is invalid with Spinner", new NotBlankConstraint(generateSpinner(BLANK), PROPERTY_NAME).validate()); }
@NonNull @Override public Set<Violation> validate() throws UnsupportedException { final Set<Violation> violations = new HashSet<>(); final String value = getStringFromObject(object, propertyName); if (null == value || 0 == value.trim().length()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_IS_BLANK)); } return violations; }
NotBlankConstraint extends Constraint<Object> { @NonNull @Override public Set<Violation> validate() throws UnsupportedException { final Set<Violation> violations = new HashSet<>(); final String value = getStringFromObject(object, propertyName); if (null == value || 0 == value.trim().length()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_IS_BLANK)); } return violations; } }
NotBlankConstraint extends Constraint<Object> { @NonNull @Override public Set<Violation> validate() throws UnsupportedException { final Set<Violation> violations = new HashSet<>(); final String value = getStringFromObject(object, propertyName); if (null == value || 0 == value.trim().length()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_IS_BLANK)); } return violations; } NotBlankConstraint(@NonNull Object object, @NonNull String propertyName); }
NotBlankConstraint extends Constraint<Object> { @NonNull @Override public Set<Violation> validate() throws UnsupportedException { final Set<Violation> violations = new HashSet<>(); final String value = getStringFromObject(object, propertyName); if (null == value || 0 == value.trim().length()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_IS_BLANK)); } return violations; } NotBlankConstraint(@NonNull Object object, @NonNull String propertyName); @NonNull @Override Set<Violation> validate(); void setMessage(String message); }
NotBlankConstraint extends Constraint<Object> { @NonNull @Override public Set<Violation> validate() throws UnsupportedException { final Set<Violation> violations = new HashSet<>(); final String value = getStringFromObject(object, propertyName); if (null == value || 0 == value.trim().length()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_IS_BLANK)); } return violations; } NotBlankConstraint(@NonNull Object object, @NonNull String propertyName); @NonNull @Override Set<Violation> validate(); void setMessage(String message); static final String ERROR_CODE_IS_BLANK; }