Groovy Documentation

## org.codehaus.groovy.grails.validation
[Java] Class ValidatorConstraint

    java.lang.Object
      org.codehaus.groovy.grails.validation.AbstractConstraint
          org.codehaus.groovy.grails.validation.ValidatorConstraint

    public class ValidatorConstraint
    extends AbstractConstraint

A constraint class that validates using a user-supplied closure.

The Closure will receive one or two parameters containing the new value of the property and the object on which the validation is being performed. The value is always the first parameterm and the object is the second. These parameters must be type compatible with the value of the property and constrained class.

The Closure can return any of:

- NULL to indicate success
- true to indicate success
- false to indicate a failure, with the default failure message
- a string to indicate a failure with the specific error code which will be appended to the prefix for the constrained class and property i.e. classname.propertyname.stringfromclosurehere
- a list containing an error code and any other arguments for the error message. The error code will be appended to the standard classname.propertyname prefix and the arguments made available to the error message as parameters numbered 3 onwards.

Authors:
  Marc Palmer

Since:
  0.4

Field Summary

Fields inherited from class AbstractConstraint
classShortName, constraintOwningClass, constraintParameter, constraintPropertyName, messageSource

Method Summary
`java.lang.String` | `getName()`
`protected void` | `processValidate(java.lang.Object target, java.lang.Object propertyValue, Errors errors)`
`void` | `setParameter(java.lang.Object constraintParameter)`
`protected boolean` | `skipBlankValues()`
`protected boolean` | `skipNullValues()`
`boolean` | `supports(java.lang.Class type)`

Methods inherited from class AbstractConstraint
checkState, getDefaultMessage, getPropertyName, processValidate, rejectValue, rejectValue, rejectValue, rejectValue, rejectValue, rejectValueWithDefaultMessage, setMessageSource, setOwningClass, setParameter, setPropertyName, skipBlankValues, skipNullValues, toString, validate

Method Detail

### getName

    public java.lang.String getName()

### processValidate

    @Override
    protected void processValidate(java.lang.Object target, java.lang.Object propertyValue, Errors errors)

### setParameter

    @Override
    public void setParameter(java.lang.Object constraintParameter)

### skipBlankValues

    @Override
    protected boolean skipBlankValues()

### skipNullValues

    @Override
    protected boolean skipNullValues()

### supports

    @SuppressWarnings("rawtypes")
    public boolean supports(java.lang.Class type)

Groovy Documentation