Package: org.grails.plugins.web.taglib

## [Groovy] Class ValidationTagLib

- org.grails.plugins.web.taglib.ValidationTagLib

- All Implemented Interfaces and Traits:
    TagLibrary

      @TagLib
      class ValidationTagLib
      extends java.lang.Object

  Tags to handle validation and errors.

  Authors:
    Graeme Rocher

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static java.lang.Object` | `CONSTRAINT_TYPE_MAP`
    `CodecLookup` | `codecLookup`
    `groovy.lang.Closure` | `eachError` Loops through each error of the specified bean or model.
    `groovy.lang.Closure` | `fieldError` Renders an error message for the given bean and field.
    `groovy.lang.Closure` | `fieldValue` Obtains the value of a field either from the original errors.
    `groovy.lang.Closure` | `hasErrors` Checks if the request has errors either for a field or global errors.
    `groovy.lang.Closure` | `message` Resolves a message code for a given error or code from the resource bundle.
    `org.springframework.context.MessageSource` | `messageSource`
    `groovy.lang.Closure` | `renderErrors` Loops through each error and renders it using one of the supported mechanisms (defaults to "list" if unsupported).
    `static java.lang.Object` | `returnObjectForTags`
    `groovy.lang.Closure` | `validate` Validates a form using Apache commons validator javascript against constraints defined in a Grails domain class.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `java.lang.Object` | `eachErrorInternal(java.lang.Object attrs, java.lang.Object body, boolean outputResult = false)`
    `` | `java.lang.Object` | `eachErrorInternalForList(java.lang.Object attrs, java.lang.Object errorsList, java.lang.Object body, boolean outputResult = false)`
    `` | `java.lang.Object` | `extractErrors(java.lang.Object attrs)`
    `` | `java.lang.Object` | `formatValue(java.lang.Object value, java.lang.String propertyPath = null, java.lang.Boolean tagSyntaxCall = false)` Formats a given value for output to an HTML page by converting it to a string and encoding it.
    `` | `java.lang.Object` | `messageImpl(java.util.Map attrs)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Property Detail

    - #### static java.lang.Object CONSTRAINT_TYPE_MAP

    - #### CodecLookup codecLookup

    - #### groovy.lang.Closure eachError

      Loops through each error of the specified bean or model. If no arguments are specified it will go through all model attributes and check for errors.

      attr:
        bean The bean to check for errors
      attr:
        field The field of the bean or model reference to check
      attr:
        model The model reference to check for errors

    - #### groovy.lang.Closure fieldError

      Renders an error message for the given bean and field.
      eg. <g:fieldError bean="${book}" field="title" />

      attr:
        bean REQUIRED The bean to check for errors
      attr:
        field REQUIRED The field of the bean or model reference to check
      attr:
        message The object to resolve the message for. Objects must implement org.springframework.context.MessageSourceResolvable.
      attr:
        encodeAs The name of a codec to apply, i.e. HTML, JavaScript, URL etc
      attr:
        locale override locale to use instead of the one detected

    - #### groovy.lang.Closure fieldValue

      Obtains the value of a field either from the original errors.
      eg. <g:fieldValue bean="${book}" field="title" />

      emptyTag:
        @attr bean REQUIRED The bean to check for errors
      attr:
        field REQUIRED The field of the bean or model reference to check
      attr:
        valueMessagePrefix Setting this allows the value to be resolved from the I18n messages.

    - #### groovy.lang.Closure hasErrors

      Checks if the request has errors either for a field or global errors.

      attr:
        bean The bean to check for errors
      attr:
        field The field of the bean or model reference to check
      attr:
        model The model reference to check for errors

    - #### groovy.lang.Closure message

      Resolves a message code for a given error or code from the resource bundle.

      emptyTag:
        @attr error The error to resolve the message for. Used for built-in Grails messages.
      attr:
        message The object to resolve the message for. Objects must implement org.springframework.context.MessageSourceResolvable.
      attr:
        code The code to resolve the message for. Used for custom application messages.
      attr:
        args A list of argument values to apply to the message, when code is used.
      attr:
        default The default message to output if the error or code cannot be found in messages.properties.
      attr:
        encodeAs The name of a codec to apply, i.e. HTML, JavaScript, URL etc
      attr:
        locale override locale to use instead of the one detected

    - #### org.springframework.context.MessageSource messageSource

    - #### groovy.lang.Closure renderErrors

      Loops through each error and renders it using one of the supported mechanisms (defaults to "list" if unsupported).

      emptyTag:
        @attr bean The bean to check for errors
      attr:
        field The field of the bean or model reference to check
      attr:
        model The model reference to check for errors

    - #### static java.lang.Object returnObjectForTags

    - #### groovy.lang.Closure validate

      Validates a form using Apache commons validator javascript against constraints defined in a Grails domain class.
      TODO: This tag is a work in progress

      attr:
        form REQUIRED the HTML form name
      attr:
        againstClass REQUIRED the domain class name

  - ### Method Detail

    - #### java.lang.Object eachErrorInternal(java.lang.Object attrs, java.lang.Object body, boolean outputResult = false)

    - #### java.lang.Object eachErrorInternalForList(java.lang.Object attrs, java.lang.Object errorsList, java.lang.Object body, boolean outputResult = false)

    - #### java.lang.Object extractErrors(java.lang.Object attrs)

    - #### java.lang.Object formatValue(java.lang.Object value, java.lang.String propertyPath = null, java.lang.Boolean tagSyntaxCall = false)

      Formats a given value for output to an HTML page by converting it to a string and encoding it. If the value is a number, it is formatted according to the current user's locale during the conversion to a string.

    - #### @groovy.transform.CompileStatic java.lang.Object messageImpl(java.util.Map attrs)