Studio Developer Manual / Version 2110
Table Of ContentsThe declaration of validators is identical for our predefined validators and for your custom validators. There are two ways to declare validators:
As Spring beans
As Json configuration files
Validator Spring beans can be located in the application or in plugins. All relevant interfaces are extension points.
Json configuration files for validators must adhere to the naming pattern
validation/captype/**/*-validator-configuration.json
.
They are detected in three locations:
In the application class path
As plugin resources
In the file system, in directories to be configured by the list-valued application property
validator.configuration-directories
If you know your validation requirements already at development time, it is easier to use Spring beans. Json configuration files are more suitable if validation decisions are made lately in the deployment process. They require the implementation and provision of validator factories, which means some extra effort when developing custom validators. You can mix validator Spring beans and Json configuration files in your application.
Most predefined validator classes of the Shared/Middle layer support declaration by Json files, except of a few which make only sense as singletons and are provided by default anyway. In case of doubt, check whether the API documentation of the validator mentions a factoryId for Json declaration at class level.
A Spring Boot actuator endpoint exposes a Json schema to assist in writing validator configuration files.
The schema follows draft-07 and contains
the schemas of all available validator factories.
The endpoint id is validatorschema
.
As some IDEs only support schemas at URLs ending on .json, the schema is also available at
validatorschema/schema.json
.
A declared validator is active by default. However, you can deactivate each validator by an application property. So, you should not hesitate to declare a validator in case of doubt.