joi-router
joi-router copied to clipboard
Feature: Allow multiple types
It seems it would make sense to allow clients to request resources with either json, url encoded or form data. All three could be allowed by the API.
Currently the type
argument in the validation is only accepting a string.
I could create a PR that would accept an array too.
Thinking about it, why is it even relevant in which format the clients sends the data? If this middleware can decode it and provide it as structured data in the body then the route should not dictate a singular format. What do you think?
I went ahead and implemented this on my fork of the project: https://github.com/Saghen/joi-router
Please note though that this fork is currently a heavy wip.
:+1: Which commit brought that feature into your fork?
A goal of this module is to fail as fast as possible on invalid input. No guessing means less bugs in my APIs. Accepting multiple formats by using an array seems like a good idea.
Any updates on the issue?