use of org.grails.validation.MatchesConstraint in project grails-core by grails.
the class ConstrainedProperty method setMatches.
/**
* @param regex The matches to set.
*/
public void setMatches(String regex) {
if (!isValidStringType()) {
throw new ConstraintException("Matches constraint can only be applied to String properties");
}
Constraint c = appliedConstraints.get(MATCHES_CONSTRAINT);
if (regex == null) {
appliedConstraints.remove(MATCHES_CONSTRAINT);
} else {
if (c == null) {
c = new MatchesConstraint();
c.setOwningClass(owningClass);
c.setPropertyName(propertyName);
appliedConstraints.put(MATCHES_CONSTRAINT, c);
}
c.setParameter(regex);
}
}
Aggregations