Closed vladfaust closed 6 years ago
@vladfaust This is great!
Right now, Amber has params validation but the conversion to the type doesn't happen until consumed by the model. Moving this up the chain to validate the types either when performing params parsing or earlier in the chain would be ideal.
@eliasjpr did most of the work on the params validator. His input would be valuable here.
First i was also more in favor of dot notation for accessing the params but now it think named tuple is best suited for the job because it's immutable and it's a struct. Also it "feels" like any other param implementation out there.
BTW, current params implementation has been inspired by @hanami :smiley:
ah! I'm a big fan of @hanami
Prism is famous for its strict params typing allowing nesting and array params as well. I'm proud of that and it's initially has been a goal for this project - typed params.
I know that other frameworks lack in this type of functionality and I'd like to extract it into a separate shard.
@paulsmith said that it would be better to make
Params
a class and make all params accessible by a method (e.g.params.user.email
). Also there was a thought of making it abstract so it works not only with HTTP params, but with other data inputs.How do you see an ideal shard for such a functionality? Take your time, see the code (start from https://github.com/vladfaust/prism/blob/master/src/prism/params.cr).
/cc @drujensen