Annotation Interface OnValidate


Annotates a Permazen model class method that should be invoked any time the associated model object is validated.

This annotation does not change when an object will be enqueued for validation. It only affects the behavior once validation of an instance is actually performed.

When validating an object, validation via @OnValidate methods occurs after JSR 303 validation, if any.

An optional list of validation groups() may be specified; if so, the annotated method will only be invoked when one or more of specified validation groups (or a superclass thereof) is being validated. In particular, if groups() is non-empty and does not contain a class that extends Default, then the method will not be invoked by automatic validation.

The annotated method must be an instance method (i.e., not static), return void, and take zero parameters. If validation fails, the method should throw a ValidationException.

Meta-Annotations

This annotation may be configured indirectly as a Spring meta-annotation when spring-core is on the classpath.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
    Specify the validation group(s) for which the annotated method should be invoked.
  • Element Details

    • groups

      Class<?>[] groups
      Specify the validation group(s) for which the annotated method should be invoked.
      Returns:
      validation group(s) to use for validation; if empty, Default is assumed
      Default:
      {}