Open-EO / openeo-js-client

JavaScript and TypeScript client for the openEO API.
https://open-eo.github.io/openeo-js-client/latest/
Apache License 2.0
15 stars 6 forks source link

Validate whether user input passes API constraints? #8

Closed christophfriedrich closed 5 years ago

christophfriedrich commented 5 years ago

For example, a collection name must pass the regex ^[A-Za-z0-9_\-\.~\/]+$, so I implemented a regex in the describeCollection method that checks whether the user-supplied name parameter adheres to it.

Pro:

Con:

Therefore I'm considering to remove that regex.

m-mohr commented 5 years ago

I don't see many of the cons as cons - regexp speed is not a problem for example - but overall I'm neutral.

mkadunc commented 5 years ago

I agree with removing this, primarily because of SSOT and 4th bullet in the Con section above.

Validation in the client API only makes sense in so far as it produces a different result than the alternative (which is validation on the server-side) - eagerly checking parameters in a function only to have them checked again further down the stack is just extra code for no apparent gain.

If the regex-checking code was auto-generated from the API schema, it might make sense to have this on the client, until then I suggest to go with the least possible code duplication.

christophfriedrich commented 5 years ago

Thanks for your feedback Miha, that was the last impulse to make me remove it. This issue will auto-close once that commit is merged into the main repo's master branch.

christophfriedrich commented 5 years ago

Meanwhile that commit has been merged into the development branch here.