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

Support more complex input relation checks in RequestValidator #57

Closed clone1612 closed 3 months ago

clone1612 commented 3 months ago

Consider an API with query parameters sector & institution that have the following relation:

The current methods from RequestValidator cannot express this, the closest we have is when(boolean condition, Consumer<RequestValidator> requestValidatorConsumer) but that doesn't result in a response which expresses the relation.

I believe adding a method for this scenario would be useful, although I don't have an immediate idea for its name. Maybe requireDependency ?

jpraet commented 3 months ago

Yes, I think this type of check may be worth supporting / standardizing. This study states it as the most common type of cross-parameter validation.

But the standardization process of these cross-parameter input validation issues has not been going smoothly as it is. I'm therefore a bit hesitant on adding yet another issue type to the proposal.

Perhaps we can implement it without introducing a new issue type, and reuse the existing urn:problem-type:belgif:input-validation:requiredInput = Input is required in this context. With a detail message that expresses the relation between both parameters, and referencing both parameters in the (also not standardized) inputs[] array.

@pvdbosch what do you think?