belgif / rest-problem-java

Java library for RFC 9457 Problems with support for standard problem types of the Belgif REST guide (https://www.belgif.be/specification/rest/api-guide/#error-handling)
https://belgif.github.io/rest-problem-java/
Apache License 2.0
3 stars 0 forks source link

Consider adding a "nullOrNotBlank" method to RequestValidator #58

Closed clone1612 closed 3 months ago

clone1612 commented 3 months ago

The OpenAPI generator plugin doesn't add @NotBlank/@NotEmpty annotations to the generated interfaces: https://stackoverflow.com/questions/77515177/openapi-generator-do-not-insert-notblank-annotation-for-string

A workaround is to add x-field-extra-annotation: "@jakarta.validation.constraints.NotBlank" hints to the schema, but that's not exactly clean. As not all parameters have a regex we can use to enforce certain content we sometimes have to check that in our code.

The idea would be to add a nullOrNotBlank(Input<String>... inputs) method to the RequestValidator that allows us to integrate that check with others in the validator (without resorting to the more verbose .custom(...) method). Maybe it's a bit too specific? What do you think?

jpraet commented 3 months ago

The RequestValidator is mainly meant for validations that cannot be enforced through the openapi schema.