@ScriptValidation annotation

back to index

Action

(Available since v1.1)
Requires that a value conforms to a scripted validation. The script can be specified either in the same location or can be placed in an external location. The script receives the following variables :

The script must return true if the data is valid, or false otherwise

Javadoc Ref :  Javadoc reference@ScriptValidation

 Input Types 1
Object
 Output Types
Same as input
   

1Automatic conversion will take place if the provided input does not match any of the input classes, as described in the conversions part of the manual.

Arguments

language

Language of the script. Default is "JavaScript".

script
Script code
scriptResource
Name of an external resource containing the script code
resourceEncoding
If the script is specified externally, this attribute specifies the character encoding used in the resource. Default is iso-8859-1
exceptionPolicy

Specifies what happens if the script throws an exception. Can be one of the following values (all of them belonging to the Javadoc referenceExceptionPolicy enumeration)

  • ASSUME_ VALID : The value is assumed to be valid
  • ASSUME_INVALID : The value is assumed to be invalid
  • PROPAGATE : The exception is propagated to the user code as a Javadoc reference HandlerException
scriptFunction

Specifies which function from the script to call. If not specified, the script will be executed using "immediate mode". Otherwise, the specified function will be invoked, and will be passed the following parameters (in order):

  • Validation environment
  • Property name
  • Object instance
  • Data value to be validated

The function must return a true/false result.

message

Literal message to use if validation fails.

errorCode
Error code to use if validation fails.
messageKey
Message key to use if validation fails.

 

Example

@ScriptValidation(script="__data > 3")
private int field;