Groovy Documentation

org.codehaus.groovy.grails.validation
[Java] Interface Constraint

org.codehaus.groovy.grails.validation.Constraint
  org.springframework.context.MessageSourceAware
All Superinterfaces:
MessageSourceAware

public interface Constraint
extends MessageSourceAware

Defines a validatable constraint.

Authors:
Graeme Rocher


Method Summary
java.lang.String getName()

@return The name of the constraint

java.lang.String getPropertyName()

@return The property name of the constraint

void setMessageSource(MessageSource source)

The message source to evaluate the default messages from

void setOwningClass(java.lang.Class owningClass)

The class the constraint applies to

void setParameter(java.lang.Object parameter)

The parameter which the constraint is validated against.

void setPropertyName(java.lang.String propertyName)

The name of the property the constraint applies to

boolean supports(java.lang.Class type)

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

void validate(java.lang.Object target, java.lang.Object propertyValue, Errors errors)

Validate this constraint against a property value.

 

Method Detail

getName

public java.lang.String getName()
Returns:
The name of the constraint


getPropertyName

public java.lang.String getPropertyName()
Returns:
The property name of the constraint


setMessageSource

public void setMessageSource(MessageSource source)
The message source to evaluate the default messages from
Parameters:
source


setOwningClass

@SuppressWarnings("rawtypes")
public void setOwningClass(java.lang.Class owningClass)
The class the constraint applies to
Parameters:
owningClass


setParameter

public void setParameter(java.lang.Object parameter)
The parameter which the constraint is validated against.
Parameters:
parameter


setPropertyName

public void setPropertyName(java.lang.String propertyName)
The name of the property the constraint applies to
Parameters:
propertyName


supports

@SuppressWarnings("rawtypes")
public boolean supports(java.lang.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

public void validate(java.lang.Object target, java.lang.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


 

Groovy Documentation