New notation for array inputs
Hey @sunny !!
Thanks for the amazing work :D
I have an idea, regarding inputs and outputs.
What do you think about accepting a new notation when expecting an array of similar objects, such as:
inputs :orders, type: [Orders]
(Similar to the GraphQL notation)
This way it will be easier to type arrays.
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 array: true option could make it much more explicit:
input :order, type: Order
input :orders, type: Order, array: true
@williampollet Would you be willing to try a patch for this feature using the array: true syntax? šš»
I'm taking it !
One import disadvantage of array: true it that it won't support type: [T, [T]] input constraints usecase.
In gerenal [T] seems to be more generic ADT-like approach
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.
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?