| //// |
| ******************************************************************* |
| * Copyright (c) 2019 Eclipse Foundation |
| * |
| * This specification document is made available under the terms |
| * of the Eclipse Foundation Specification License v1.0, which is |
| * available at https://www.eclipse.org/legal/efsl.php. |
| ******************************************************************* |
| //// |
| |
| [[default_validation_mode]] |
| === Default Validation Mode |
| |
| According to <<bib16>>, validation is enabled by default only for |
| the so called _constrained_ methods. Getter methods as defined by the |
| Java Beans specification are not constrained methods, so they will not |
| be validated by default. The special annotation `@ValidateOnExecution` |
| defined in <<bib16>> can be used to selectively enable and disable |
| validation. For example, you can enable validation on method `getEmail` |
| shown above as follows: |
| |
| [source,java] |
| ---- |
| @Path("/") |
| class MyResourceClass { |
| |
| @Email |
| @ValidateOnExecution |
| public String getEmail() { |
| return email; |
| } |
| ... |
| } |
| ---- |
| |
| The default value for the `type` attribute of `@ValidateOnExecution` is |
| `IMPLICIT` which, in the example above, results in method `getEmail` |
| being validated. See <<bib16>> for more information on other uses |
| of this annotation. |
| |
| Note that if validation for getter methods is _enabled_ and a resource |
| method’s signature obeys the rules for getters, the resource method may |
| be (unintentionally) invoked during validation. Conversely, if |
| validation for getter methods is _disabled_ and the _matching_ resource |
| method’s signature obeys the rules for getters, the JAX-RS runtime will |
| still validate the method (i.e., the validation preference will be |
| ignored) before invocation. |