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