org.appng.api.support.validation

## Class DefaultValidationProvider

- java.lang.Object
- - org.appng.api.support.validation.DefaultValidationProvider

- All Implemented Interfaces:
    ValidationProvider

      public class DefaultValidationProvider
      extends Object
      implements ValidationProvider

  Default `ValidationProvider` implementation.
  Author:
    Matthias Müller

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultValidationProvider()` Creates a new `DefaultValidationProvider` using the `MessageInterpolator` returned from `ValidatorFactory.getMessageInterpolator()`.
    `DefaultValidationProvider(javax.validation.MessageInterpolator messageInterpolator, org.springframework.context.MessageSource messageSource, Locale locale)` Creates a new `DefaultValidationProvider`.
    `DefaultValidationProvider(javax.validation.MessageInterpolator messageInterpolator, org.springframework.context.MessageSource messageSource, Locale locale, boolean contraintsAsRule)` Creates a new `DefaultValidationProvider`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addMessage(FieldDef field, ValidationRule validationRule, String messageTemplate, String messageText)`
    `void` | `addValidationMetaData(MetaData metaData, ClassLoader classLoader, Class<?>... groups)` Based on the JSR-303 annotations of the `MetaData`'s bindclass, this method adds the `Validation` to the `FieldDef`initions.
    `protected Rule` | `getRule(Annotation annotation, String type)`
    `void` | `validateBean(Object bean, FieldProcessor fp, Class<?>... groups)` Validates the given bean by adding error-messages to the `FieldDef` initions, using `FieldProcessor.addErrorMessage(FieldDef, String)`.
    `void` | `validateBean(Object bean, FieldProcessor fp, String[] excludeBindings, Class<?>... groups)` Validates the given bean by adding error-messages to the `FieldDef` initions, using `FieldProcessor.addErrorMessage(FieldDef, String)`.
    `void` | `validateField(Object bean, FieldProcessor fp, String fieldBinding, Class<?>... groups)` Validates a single `FieldDef` by adding error-messages to it, using `FieldProcessor.addErrorMessage(FieldDef, String)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultValidationProvider

          public DefaultValidationProvider(javax.validation.MessageInterpolator messageInterpolator,
                                           org.springframework.context.MessageSource messageSource,
                                           Locale locale)

      Creates a new `DefaultValidationProvider`.
      Parameters:
        `messageInterpolator` - the `MessageInterpolator` used when adding validation messages
        `messageSource` - the `MessageSource` used when adding validation messages
        `locale` - the `Locale` used when adding validation messages

    - #### DefaultValidationProvider

          public DefaultValidationProvider(javax.validation.MessageInterpolator messageInterpolator,
                                           org.springframework.context.MessageSource messageSource,
                                           Locale locale,
                                           boolean contraintsAsRule)

      Creates a new `DefaultValidationProvider`.
      Parameters:
        `messageInterpolator` - the `MessageInterpolator` used when adding validation messages
        `messageSource` - the `MessageSource` used when adding validation messages
        `locale` - the `Locale` used when adding validation messages
        `contraintsAsRule` - whether validation constraints should be added as a `Rule` to the `FieldDef`s `Validation`

    - #### DefaultValidationProvider

          public DefaultValidationProvider()

      Creates a new `DefaultValidationProvider` using the `MessageInterpolator` returned from `ValidatorFactory.getMessageInterpolator()`.

  - ### Method Detail

    - #### addValidationMetaData

          public void addValidationMetaData(MetaData metaData,
                                            ClassLoader classLoader,
                                            Class<?>... groups)
                                     throws ClassNotFoundException

      Description copied from interface: `ValidationProvider`
      Based on the JSR-303 annotations of the `MetaData`'s bindclass, this method adds the `Validation` to the `FieldDef`initions.
      Specified by:
        `addValidationMetaData` in interface `ValidationProvider`
      Parameters:
        `metaData` - the `MetaData` to add the `Validation`s to
        `classLoader` - the `ClassLoader` to load the `MetaData`s bindClass
        `groups` - the JSR-303 validation groups to use
      Throws:
        `ClassNotFoundException` - if the bindClass can not be loaded
      See Also:
        `Min`, `Max`, `Size`, `Digits`, `NotNull`, `Future`, `Past`, `Type`, `Pattern`, `FileUpload`

    - #### getRule

          protected Rule getRule(Annotation annotation,
                                 String type)

    - #### addMessage

          protected void addMessage(FieldDef field,
                                    ValidationRule validationRule,
                                    String messageTemplate,
                                    String messageText)

    - #### validateBean

          public void validateBean(Object bean,
                                   FieldProcessor fp,
                                   Class<?>... groups)

      Description copied from interface: `ValidationProvider`
      Validates the given bean by adding error-messages to the `FieldDef` initions, using `FieldProcessor.addErrorMessage(FieldDef, String)`.
      Specified by:
        `validateBean` in interface `ValidationProvider`
      Parameters:
        `bean` - the bean to validate
        `fp` - the `FieldProcessor` containing the `MetaData` for the bean
        `groups` - the JSR-303 validation groups to use
      See Also:
        `FieldProcessor.addErrorMessage(FieldDef, String)`

    - #### validateBean

          public void validateBean(Object bean,
                                   FieldProcessor fp,
                                   String[] excludeBindings,
                                   Class<?>... groups)

      Description copied from interface: `ValidationProvider`
      Validates the given bean by adding error-messages to the `FieldDef` initions, using `FieldProcessor.addErrorMessage(FieldDef, String)`.
      Specified by:
        `validateBean` in interface `ValidationProvider`
      Parameters:
        `bean` - the bean to validate
        `fp` - the `FieldProcessor` containing the `MetaData` for the bean
        `excludeBindings` - an array of field-bindings to ignore during validation
        `groups` - the JSR-303 validation groups to use
      See Also:
        `FieldProcessor.addErrorMessage(FieldDef, String)`

    - #### validateField

          public void validateField(Object bean,
                                    FieldProcessor fp,
                                    String fieldBinding,
                                    Class<?>... groups)

      Description copied from interface: `ValidationProvider`
      Validates a single `FieldDef` by adding error-messages to it, using `FieldProcessor.addErrorMessage(FieldDef, String)`.
      Specified by:
        `validateField` in interface `ValidationProvider`
      Parameters:
        `bean` - the bean to validate
        `fp` - the `FieldProcessor` containing the `MetaData` for the bean
        `fieldBinding` - the binding of the `FieldDef` to validate
        `groups` - the JSR-303 validation groups to use
      See Also:
        `FieldProcessor.addErrorMessage(FieldDef, String)`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.