onyxframework / http

An opinionated framework for scalable web 🌎
https://onyxframework.com/http
MIT License
142 stars 11 forks source link

Extract params to an external shard #44

Closed vladfaust closed 6 years ago

vladfaust commented 6 years ago

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

drujensen commented 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.

repomaa commented 6 years ago

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.

vladfaust commented 6 years ago

BTW, current params implementation has been inspired by @hanami :smiley:

repomaa commented 6 years ago

ah! I'm a big fan of @hanami