Package com.isomorphic.datasource
Class Validator
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
com.isomorphic.datasource.Validator
- All Implemented Interfaces:
com.isomorphic.util.IDoNotAdapt
,Serializable
,Cloneable
,Map
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:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addErrorMessageVariable
(String name, String value) Adds a variable to the context used when building error messages for this Validator.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.Returns the error messageRetrieves the current map of error message variables for this ValidatorReturns language property, which is script language of serverCondition expression that will be executed by the server.getListProperty
(String property) Returns the value of the specified attribute as a List.getMapProperty
(String property) Returns the value of the specified attribute as a Map.getObjectProperty
(String property) Returns the value of the specified element(s) as an Object.getProperty
(String property) Returns the value of the specified attribute as a string.Returns script imports, which are used by script defined in serverCondition expression that will be executed by the server.Returns the server condition, which is an expression that will be executed by the server.getType()
Returns the Validator typeboolean
Returns whether this Validator is intended to run only on the clientboolean
Returns whether this Validator is intended to run only on the serverboolean
Returns true if validation should stop if this Validator fails.
-
Method Details
-
getProperty
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:
-
getObjectProperty
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:
-
getListProperty
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:
ClassCastException
- if requested property is not instanceof List- See Also:
-
getMapProperty
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:
ClassCastException
- if requested property is not instanceof Map- See Also:
-
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
Returns the error message- Returns:
- the error message
-
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
Returns script imports, which are used by script defined in serverCondition expression that will be executed by the server.- Returns:
- the server condition
-
getLanguage
Returns language property, which is script language of serverCondition expression that will be executed by the server.- Returns:
- the server condition
-
getType
Returns the Validator type- Returns:
- the validator type
-
addErrorMessageVariable
Adds a variable to the context used when building error messages for this Validator.- Parameters:
name
- the name to give the variable in the contextvalue
- the value to associate with the variable
-
getErrorMessageVariables
Retrieves the current map of error message variables for this Validator- Returns:
- The Map of error message variables
-
evaluateErrorMessage
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:
Exception
-