Search in sources :

Example 1 with CreditCardConstraint

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);
        }
    }
}
Also used : MaxSizeConstraint(org.grails.validation.MaxSizeConstraint) MinConstraint(org.grails.validation.MinConstraint) SizeConstraint(org.grails.validation.SizeConstraint) MinSizeConstraint(org.grails.validation.MinSizeConstraint) BlankConstraint(org.grails.validation.BlankConstraint) RangeConstraint(org.grails.validation.RangeConstraint) ValidatorConstraint(org.grails.validation.ValidatorConstraint) ScaleConstraint(org.grails.validation.ScaleConstraint) NullableConstraint(org.grails.validation.NullableConstraint) MaxConstraint(org.grails.validation.MaxConstraint) CreditCardConstraint(org.grails.validation.CreditCardConstraint) UrlConstraint(org.grails.validation.UrlConstraint) InListConstraint(org.grails.validation.InListConstraint) MatchesConstraint(org.grails.validation.MatchesConstraint) NotEqualConstraint(org.grails.validation.NotEqualConstraint) EmailConstraint(org.grails.validation.EmailConstraint) CreditCardConstraint(org.grails.validation.CreditCardConstraint) ConstraintException(grails.validation.exceptions.ConstraintException)

Aggregations

ConstraintException (grails.validation.exceptions.ConstraintException)1 BlankConstraint (org.grails.validation.BlankConstraint)1 CreditCardConstraint (org.grails.validation.CreditCardConstraint)1 EmailConstraint (org.grails.validation.EmailConstraint)1 InListConstraint (org.grails.validation.InListConstraint)1 MatchesConstraint (org.grails.validation.MatchesConstraint)1 MaxConstraint (org.grails.validation.MaxConstraint)1 MaxSizeConstraint (org.grails.validation.MaxSizeConstraint)1 MinConstraint (org.grails.validation.MinConstraint)1 MinSizeConstraint (org.grails.validation.MinSizeConstraint)1 NotEqualConstraint (org.grails.validation.NotEqualConstraint)1 NullableConstraint (org.grails.validation.NullableConstraint)1 RangeConstraint (org.grails.validation.RangeConstraint)1 ScaleConstraint (org.grails.validation.ScaleConstraint)1 SizeConstraint (org.grails.validation.SizeConstraint)1 UrlConstraint (org.grails.validation.UrlConstraint)1 ValidatorConstraint (org.grails.validation.ValidatorConstraint)1