@Test public void isInValid() throws Exception { assertNotEmpty("is invalid with String", new MatchConstraint(INVALID, PATTERN, PROPERTY_NAME).validate()); assertNotEmpty("is invalid with String", new MatchConstraint(NULL, PATTERN, PROPERTY_NAME).validate()); assertNotEmpty("is invalid with EdiText", new MatchConstraint(generateEditText(INVALID), PATTERN, PROPERTY_NAME).validate()); assertNotEmpty("is invalid with Spinner", new MatchConstraint(generateSpinner(INVALID), PATTERN, 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 || !pattern.matcher(value).matches()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_NOT_MATCH)); } return violations; }
MatchConstraint 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 || !pattern.matcher(value).matches()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_NOT_MATCH)); } return violations; } }
MatchConstraint 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 || !pattern.matcher(value).matches()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_NOT_MATCH)); } return violations; } MatchConstraint(@NonNull Object object, @NonNull Pattern pattern, @NonNull String propertyName); }
MatchConstraint 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 || !pattern.matcher(value).matches()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_NOT_MATCH)); } return violations; } MatchConstraint(@NonNull Object object, @NonNull Pattern pattern, @NonNull String propertyName); @NonNull @Override Set<Violation> validate(); void setMessage(String message); }
MatchConstraint 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 || !pattern.matcher(value).matches()) { violations.add(new Violation(propertyName, value, message, ERROR_CODE_NOT_MATCH)); } return violations; } MatchConstraint(@NonNull Object object, @NonNull Pattern pattern, @NonNull String propertyName); @NonNull @Override Set<Violation> validate(); void setMessage(String message); static final String ERROR_CODE_NOT_MATCH; }