## org.codehaus.groovy.grails.validation
Interface Constraint

All Superinterfaces:
  MessageSourceAware

All Known Subinterfaces:
  PersistentConstraint, VetoingConstraint

All Known Implementing Classes:
  AbstractConstraint, AbstractPersistentConstraint, AbstractVetoingConstraint, BlankConstraint, CreditCardConstraint, EmailConstraint, InListConstraint, MatchesConstraint, MaxConstraint, MaxSizeConstraint, MinConstraint, MinSizeConstraint, NotEqualConstraint, NullableConstraint, RangeConstraint, ScaleConstraint, SizeConstraint, UniqueConstraint, UrlConstraint, ValidatorConstraint

    public interface Constraint

extends MessageSourceAware

Interface that defines a validatable constraint

Since:
  10-Nov-2005
Author:
  Graeme Rocher

Method Summary
`String` `getName()`
`String` `getPropertyName()`
`void` `setMessageSource(MessageSource source)` The message source to evaluate the default messages from
`void` `setOwningClass(Class owningClass)` The class the constraint applies to
`void` `setParameter(Object parameter)` The parameter which the constraint is validated against
`void` `setPropertyName(String propertyName)` The name of the property the constraint applies to
`boolean` `supports(Class type)` Returns whether the constraint supports being applied against the specified type;
`void` `validate(Object target, Object propertyValue, Errors errors)` Validate this constraint against a property value.

Method Detail

### supports

    boolean supports(Class type)

  Returns whether the constraint supports being applied against the specified type;

  Parameters:
    `type` - The type to support
  Returns:
    True if the constraint can be applied against the specified type

### validate

    void validate(Object target,
                  Object propertyValue,
                  Errors errors)

  Validate this constraint against a property value. If implementation is vetoing (isVetoing() method returns true), then it could return 'true' to stop further validation.

  Parameters:
    `target` -
    `propertyValue` - The property value to validate
    `errors` - The errors instance to record errors against

### setParameter

    void setParameter(Object parameter)

  The parameter which the constraint is validated against

  Parameters:
    `parameter` -

### setOwningClass

    void setOwningClass(Class owningClass)

  The class the constraint applies to

  Parameters:
    `owningClass` -

### setPropertyName

    void setPropertyName(String propertyName)

  The name of the property the constraint applies to

  Parameters:
    `propertyName` -

### getName

    String getName()

  Returns:
    The name of the constraint

### getPropertyName

    String getPropertyName()

  Returns:
    The property name of the constraint

### setMessageSource

    void setMessageSource(MessageSource source)

  The message source to evaluate the default messages from

  Specified by:
    `setMessageSource` in interface `MessageSourceAware`
  Parameters:
    `source` -

Copyright (c) 2005-2009 The Grails project