Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Auto Closed
-
None
-
None
Description
While I was fixing FINERACT-1036 (see upcoming PR), and adding a manual non-null check ad hoc for that particular problem, it occurred to me that it would be much nicer if we could simply declare validation rules by annotation, such as "required" (not null) for parameters of API Resource methods, or even fields in data classes used as parameters types.
In an ideal world, I would expect this to then be picked up by both at runtime for validation, and by the Swagger Code Gen to dig what is a required in the JSON.
jakarta.validation.constraints.NotNull seems suitable, but I've tried adding that to the respective arguments (FormDataContentDisposition and FormDataBodyPart) of theĀ org.apache.fineract.infrastructure.documentmanagement.api.DocumentManagementApiResource.createDocument() method - but it didn't seem to do anything.
I'm guessing some Spring / JAX RS / Bean Validation integration magic would be required for this. I'm sure it exists, but haven't into it - someone could look into this some time under this issue. (For the short term in FINERACT-1036, I'm manually null checking, and throwing a jakarta.validation.ValidationException - but at least already contributing the ValidationExceptionExceptionMapper which can be re-used when we implement this.
Attachments
Issue Links
- relates to
-
FINERACT-1036 NullPointerException at DocumentManagementApiResource.createDocument()
- Resolved