Open Joraeuw opened 6 months ago
Thanks for your suggestion. I hadn't planned on introducing this feature 🤔 I'll think on the idea for a bit. The same can be achieved with some business logic, and there would be a question whether it is useful to provide configurability for example for two_of_many
, three_of_many
etc
I think it can be done. In my opinion only one_of_many
and some_of_many
make sense, where some_of_many
would take an integer of how many of the provided fields are expected. Also how about adding support for structs. For example if your API expects images to be provided from the frontend. Its usually coming as the Plug.Upload
struct.
+1 for this feature. I suggest to look to grape gem for inspiration which provides options exactly_one_of
, at_least_one_of
, all_or_none_of
, mutually_exclusive
. With combination of these It's possible to have almost complete control over required params and their dependencies.
I really like this library and I would like to improve it.
I have the idea to add a
one_of_many
validation. As the name suggests it will check if only one of N fields is present.Here's a simple example: