com.isomorphic.datasource

## Class Validator

- java.lang.Object
- - java.util.AbstractMap
  - - java.util.HashMap
    - - com.isomorphic.datasource.Validator

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map

      public class Validator
      extends java.util.HashMap

  Server-side representation of a Validator.

  Contains accessors for all documented Validator properties and a general getProperty() API for retrieving your own properties for custom DataSource implementations.

  See Also:
    Serialized Form

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addErrorMessageVariable(java.lang.String name, java.lang.String value)` Adds a variable to the context used when building error messages for this Validator.
    `ErrorMessage` | `evaluateErrorMessage(ErrorMessage error)` Returns the evaluated form of the passed in error message, applying any error message variables that have been assigned to this validator.
    `java.lang.String` | `getErrorMessage()` Returns the error message
    `java.util.Map` | `getErrorMessageVariables()` Retrieves the current map of error message variables for this Validator
    `java.lang.String` | `getLanguage()` Returns language property, which is script language of serverCondition expression that will be executed by the server.
    `java.util.List` | `getListProperty(java.lang.String property)` Returns the value of the specified attribute as a List.
    `java.util.Map` | `getMapProperty(java.lang.String property)` Returns the value of the specified attribute as a Map.
    `java.lang.Object` | `getObjectProperty(java.lang.String property)` Returns the value of the specified element(s) as an Object. Custom XML is transformed to Strings or Java collections by the following rules: Elements with just text (no child elements or attributes) become Strings Elements with child elements or attributes become Maps containing data derived from their subelements Repeating elements (more than one of the same name at the same level) become Lists
    `java.lang.String` | `getProperty(java.lang.String property)` Returns the value of the specified attribute as a string.
    `java.lang.Object` | `getScriptImports()` Returns script imports, which are used by script defined in serverCondition expression that will be executed by the server.
    `java.lang.String` | `getServerCondition()` Returns the server condition, which is an expression that will be executed by the server.
    `java.lang.String` | `getType()` Returns the Validator type
    `boolean` | `isClientOnly()` Returns whether this Validator is intended to run only on the client
    `boolean` | `isServerOnly()` Returns whether this Validator is intended to run only on the server
    `boolean` | `isStopIfFalse()` Returns true if validation should stop if this Validator fails.

- - ### Method Detail

    - #### getProperty

          public java.lang.String getProperty(java.lang.String property)

      Returns the value of the specified attribute as a string.
      Parameters:
        `property` - the name of the attribute
      Returns:
        the value of the specified attribute as a string
      See Also:
        `Validator.getObjectProperty(java.lang.String)`, `Validator.getListProperty(java.lang.String)`, `Validator.getMapProperty(java.lang.String)`

    - #### getObjectProperty

          public java.lang.Object getObjectProperty(java.lang.String property)

      Returns the value of the specified element(s) as an Object.

      Custom XML is transformed to Strings or Java collections by the following rules:
      - Elements with just text (no child elements or attributes) become Strings
      - Elements with child elements or attributes become Maps containing data derived from their subelements
      - Repeating elements (more than one of the same name at the same level) become Lists

      Sample XML:

      - Map

        `<validator>
        <mapCustomProperty key1="value1" key2="value2" />
        </validator>`

      - List of String

        `<validator>
        <listCustomProperty>ListElement1</listCustomProperty>
        <listCustomProperty>ListElement2</listCustomProperty> </validator>`

      - List of Map

        `<validator>
        <mapCustomProperty key1="value1" key2="value2" />
        <mapCustomProperty key1="value1" key2="value2" />
        </validator>`

      Parameters:
        `property` - the name of the element(s)
      Returns:
        the value of the specified element(s) as an Object
      See Also:
        `Validator.getProperty(java.lang.String)`, `Validator.getListProperty(java.lang.String)`, `Validator.getMapProperty(java.lang.String)`

    - #### getListProperty

          public java.util.List getListProperty(java.lang.String property)

      Returns the value of the specified attribute as a List.
      Parameters:
        `property` - the name of the attribute
      Returns:
        the value of the specified attribute as a List
      Throws:
        `java.lang.ClassCastException` - if requested property is not instanceof List
      See Also:
        `Validator.getProperty(java.lang.String)`, `Validator.getObjectProperty(java.lang.String)`, `Validator.getMapProperty(java.lang.String)`

    - #### getMapProperty

          public java.util.Map getMapProperty(java.lang.String property)

      Returns the value of the specified attribute as a Map.
      Parameters:
        `property` - the name of the attribute
      Returns:
        the value of the specified attribute as a Map
      Throws:
        `java.lang.ClassCastException` - if requested property is not instanceof Map
      See Also:
        `Validator.getProperty(java.lang.String)`, `Validator.getObjectProperty(java.lang.String)`, `Validator.getListProperty(java.lang.String)`

    - #### isClientOnly

          public boolean isClientOnly()

      Returns whether this Validator is intended to run only on the client
      Returns:
        whether this Validator is intended to run only on the client

    - #### isServerOnly

          public boolean isServerOnly()

      Returns whether this Validator is intended to run only on the server
      Returns:
        whether this Validator is intended to run only on the server

    - #### isStopIfFalse

          public boolean isStopIfFalse()

      Returns true if validation should stop if this Validator fails. Ordinarily, all Validators for a given field run, even if one has already failed.
      Returns:
        true if validation should stop if this Validator fails

    - #### getErrorMessage

          public java.lang.String getErrorMessage()

      Returns the error message
      Returns:
        the error message

    - #### getServerCondition

          public java.lang.String getServerCondition()

      Returns the server condition, which is an expression that will be executed by the server. Script language can be defined via language property, otherwise system-wide script.validator.defaultLanguage setting will be used.
      Returns:
        the server condition

    - #### getScriptImports

          public java.lang.Object getScriptImports()

      Returns script imports, which are used by script defined in serverCondition expression that will be executed by the server.
      Returns:
        the server condition

    - #### getLanguage

          public java.lang.String getLanguage()

      Returns language property, which is script language of serverCondition expression that will be executed by the server.
      Returns:
        the server condition

    - #### getType

          public java.lang.String getType()

      Returns the Validator type
      Returns:
        the validator type

    - #### addErrorMessageVariable

          public void addErrorMessageVariable(java.lang.String name,
                                              java.lang.String value)

      Adds a variable to the context used when building error messages for this Validator.
      Parameters:
        `name` - the name to give the variable in the context
        `value` - the value to associate with the variable

    - #### getErrorMessageVariables

          public java.util.Map getErrorMessageVariables()

      Retrieves the current map of error message variables for this Validator
      Returns:
        The Map of error message variables

    - #### evaluateErrorMessage

          public ErrorMessage evaluateErrorMessage(ErrorMessage error)
                                            throws java.lang.Exception

      Returns the evaluated form of the passed in error message, applying any error message variables that have been assigned to this validator.
      Parameters:
        `error` - The message text to evaluate
      Returns:
        The evaluated error message (it is the same object as was passed in)
      Throws:
        `java.lang.Exception`