-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New notation for array inputs #39
Comments
That makes a lot of sense! I’d be happy to merge a PR for that 🙏🏻 |
Actually, since now the array syntax for types is used as an "or": input :age, type: [Integer, Float] I think it would make more sense to just keep the plural and not have an array: input :order, type: Order
inputs :orders, type: Order But perhaps better than the plural which can be a bit too discreet, having it as a new input :order, type: Order
input :orders, type: Order, array: true |
@williampollet Would you be willing to try a patch for this feature using the |
I'm taking it ! |
One import disadvantage of In gerenal |
Good point. I think I’d still like the constraints here to be as light as possible and not try to handle all possible types. One way we could accept more types would be to lean on another constraints/validation gem. |
Do you have examples of such gems in mind? |
I was thinking of dry-validations, or ActiveRecord validations (perhaps with type_validator). But there may be others. |
I think we could come up with some sort of global configuration option that will switch from our (default) type validation backend to gem-provided backend dry-rb is more popular, should I try to implement a PoC for this? @sunny |
I think it would make sense to use I don’t know what the best course of action for that would be. Maybe this means that the glue code between |
Yeah, I think we only need to expose some interface so that other gems might use it to provide 3rd-party-gem-backed validation. Also some sort of a global configuration option to select implementation |
Yeah, makes sense. We could have for example:
To allow that, perhaps the current validations could use more generic |
Could you elaborate on that? Seems like I'm missing something here |
Apart from dry-validations, can we add |
I was thinking of a way of “hooking” into actor from outside gems. Using for example Not sure this would be the best way to do that, just some thoughts.
Sure! Note that you can do a similar check today with: input :names,
type: Array,
must: {
be_strings: -> array { array.all?(String) }
} |
Hey @sunny !!
Thanks for the amazing work :D
I have an idea, regarding
inputs
andoutputs
.What do you think about accepting a new notation when expecting an array of similar objects, such as:
(Similar to the GraphQL notation)
This way it will be easier to type arrays.
The text was updated successfully, but these errors were encountered: