joi-router icon indicating copy to clipboard operation
joi-router copied to clipboard

Feature: Allow multiple types

Open pke opened this issue 5 years ago • 6 comments

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.

pke avatar Oct 10 '18 20:10 pke

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?

pke avatar Oct 17 '18 13:10 pke

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.

Saghen avatar Apr 04 '19 04:04 Saghen

:+1: Which commit brought that feature into your fork?

pke avatar Apr 04 '19 10:04 pke

Here it is

Saghen avatar Apr 04 '19 12:04 Saghen

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.

aheckmann avatar Apr 27 '19 21:04 aheckmann

Any updates on the issue?

mlshv avatar Aug 09 '19 11:08 mlshv