...
This level of validation uses the validated annotation from the spring validation library and provides pre validation on parameters being sent to the class or application. The second level of validation is provided by the java x valid annotation. This will ensure that the object on which it is called satisfy the constraint, whether that be its data type, content, length and so on. Utilization of the libraries like this is suitable for restructuring at class level for components like participants or runtime parameter handling but do not provide a common parameter handling solution. To achieve this I believe that, depending on the needs of the project or design decisions it can be achieved using the following methods.
- Decide on what library is best suited for the job, in my opinion the spring boot starter validator or hibernate validator will work but I do not know the memory implications that come with each at initial run.
- The next step will be to create the annotation interfaces that will define the class that will validate the constraint whenever the annotation is used.
- Next, validation logic must be created for the annotation and this will be a custom constraint that can be reused throughout the project.
- Once we have enough custom validators we need to focus on bean validation which can prove to be tricky to accomplish seeing as a validation class cannot be created to validate every bean when desired.