## org.codehaus.groovy.grails.validation
Class GrailsDomainClassValidator

    java.lang.Object
      org.codehaus.groovy.grails.validation.GrailsDomainClassValidator

All Implemented Interfaces:
  CascadingValidator, Validator

Direct Known Subclasses:
  HibernateDomainClassValidator

    public class GrailsDomainClassValidator

extends Object
implements Validator, CascadingValidator

A specialised Spring validator that validates a domain class instance using the constraints defined in the static constraints closure.

Since:
  0.1 Created: 07-Nov-2005
Author:
  Graeme Rocher

Constructor Summary
`GrailsDomainClassValidator()`

Method Summary
`protected void` `cascadeToAssociativeProperty(Errors errors, BeanWrapper bean, GrailsDomainClassProperty persistentProperty)` Cascades validation onto an associative property maybe a one-to-many, one-to-one or many-to-one relationship
`protected void` `cascadeValidationToMany(Errors errors, BeanWrapper bean, GrailsDomainClassProperty persistentProperty, String propertyName)` Cascades validation to a one-to-many type relationship.
`protected void` `cascadeValidationToOne(Errors errors, BeanWrapper bean, Object associatedObject, GrailsDomainClassProperty persistentProperty, String propertyName)` Cascades validation to a one-to-one or many-to-one property
`GrailsDomainClass` `getDomainClass()`
`void` `setDomainClass(GrailsDomainClass domainClass)`
`void` `setMessageSource(MessageSource messageSource)`
`boolean` `supports(Class clazz)`
`void` `validate(Object obj, Errors errors)`
`void` `validate(Object obj, Errors errors, boolean cascade)` An extended version of the validate(errors,obj) method that takes an additional argument specifying whether the Validator should cascade into associations or not

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GrailsDomainClassValidator

    public GrailsDomainClassValidator()

Method Detail

### supports

    public boolean supports(Class clazz)

  Specified by:
    `supports` in interface `Validator`

### setDomainClass

    public void setDomainClass(GrailsDomainClass domainClass)

  Parameters:
    `domainClass` - The domainClass to set.

### getDomainClass

    public GrailsDomainClass getDomainClass()

### setMessageSource

    public void setMessageSource(MessageSource messageSource)

  Parameters:
    `messageSource` - The messageSource to set.

### validate

    public void validate(Object obj,
                         Errors errors,
                         boolean cascade)

  Description copied from interface: `CascadingValidator`
  An extended version of the validate(errors,obj) method that takes an additional argument specifying whether the Validator should cascade into associations or not

  Specified by:
    `validate` in interface `CascadingValidator`
  Parameters:
    `obj` - The Object to validate
    `errors` - The Spring Errors instance
    `cascade` - True if validation should cascade into associations
  See Also:
    `CascadingValidator.validate(Object, org.springframework.validation.Errors, boolean)`

### validate

    public void validate(Object obj,
                         Errors errors)

  Specified by:
    `validate` in interface `Validator`
  See Also:
    `Validator.validate(Object, org.springframework.validation.Errors)`

### cascadeToAssociativeProperty

    protected void cascadeToAssociativeProperty(Errors errors,
                                                BeanWrapper bean,
                                                GrailsDomainClassProperty persistentProperty)

  Cascades validation onto an associative property maybe a one-to-many, one-to-one or many-to-one relationship

  Parameters:
    `errors` - The Errors instnace
    `bean` - The original bean
    `persistentProperty` - The associative property

### cascadeValidationToMany

    protected void cascadeValidationToMany(Errors errors,
                                           BeanWrapper bean,
                                           GrailsDomainClassProperty persistentProperty,
                                           String propertyName)

  Cascades validation to a one-to-many type relationship. Normally a collection such as a List or Set each element in the association will also be validated

  Parameters:
    `errors` - The Errors instance
    `bean` - The original BeanWrapper
    `persistentProperty` - An association whose isOneToMeny() method returns true
    `propertyName` - The name of the property

### cascadeValidationToOne

    protected void cascadeValidationToOne(Errors errors,
                                          BeanWrapper bean,
                                          Object associatedObject,
                                          GrailsDomainClassProperty persistentProperty,
                                          String propertyName)

  Cascades validation to a one-to-one or many-to-one property

  Parameters:
    `errors` - The Errors instance
    `bean` - The original BeanWrapper
    `associatedObject` - The associated object's current value
    `persistentProperty` - The GrailsDomainClassProperty instance
    `propertyName` - The name of the property

Copyright (c) 2005-2006 The Grails project