org.hibernate.validator.constraints

## Annotation Type ParameterScriptAssert

-     @Target(value={CONSTRUCTOR,METHOD})
      @Retention(value=RUNTIME)
      @Constraint(validatedBy={})
      @Documented
      public @interface ParameterScriptAssert

  A method-level constraint, that evaluates a script expression against the annotated method or constructor. This constraint can be used to implement validation routines that depend on several parameters of the annotated executable.

  Script expressions can be written in any scripting or expression language, for which a JSR 223 ("Scripting for the JavaTM Platform") compatible engine can be found on the classpath. To refer to a parameter within the scripting expression, use its name as obtained by the active `ParameterNameProvider`. By default, `arg0`, `arg1` etc. will be used as parameter names.

  The following listing shows an example using the JavaScript engine which comes with the JDK:

       @ParametersScriptAssert(script = "arg0.before(arg1)", lang = "javascript")
       public void createEvent(Date start, Date end) { ... }

  Can be specified on any method or constructor.

  Author:
    Gunnar Morling

- - ### Required Element Summary

    Required Elements
    Modifier and Type | Required Element and Description
    --- | ---
    `String` | `lang`
    `String` | `script`

  - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `Class<?>[]` | `groups`
    `String` | `message`
    `Class<? extends Payload>[]` | `payload`

- - ### Element Detail

    - #### lang

          public abstract String lang

      Returns:
        The name of the script language used by this constraint as expected by the JSR 223 `ScriptEngineManager`. A `ConstraintDeclarationException` will be thrown upon script evaluation, if no engine for the given language could be found.

    - #### script

          public abstract String script

      Returns:
        The script to be executed. The script must return `Boolean.TRUE`, if the executable parameters could successfully be validated, otherwise `Boolean.FALSE`. Returning null or any type other than Boolean will cause a `ConstraintDeclarationException` upon validation. Any exception occurring during script evaluation will be wrapped into a ConstraintDeclarationException, too. Within the script, the validated parameters can be accessed using their names as retrieved from the active `ParameterNameProvider`.

    - #### message

          public abstract String message

      Default:
        "{org.hibernate.validator.constraints.ParametersScriptAssert.message}"

    - #### groups

          public abstract Class<?>[] groups

      Default:
        {}

    - #### payload

          public abstract Class<? extends Payload>[] payload

      Default:
        {}

Copyright © 2007-2014 Red Hat, Inc. All Rights Reserved