These are chat archives for dry-rb/chat

1st
Aug 2016
Matt Patterson
@fidothe
Aug 01 2016 10:04
@solnic I'm chasing some issues from Hanami through validations to dry-validations, and I just want to double check something – at the moment the docs for Dry::Validation.Form make it sound like we can't use validations on form params containing File uploads (this is a problem with Hanami which #to_s's all my file uploads out of existence when checking param validity...). Is this true? I'm still unpicking the code and haven't figured out how it all fits together yet...
Piotr Solnica
@solnic
Aug 01 2016 10:08
@fidothe wdym that it #to_ss your file uploads? why would it do that?
can you show me an example?
Piotr Solnica
@solnic
Aug 01 2016 10:09
we don’t have any special predicates for file uploads, I guess doing required(:file).filled should be enough, but you could add your own checks
@fidothe sorry but I don’t know the reasoning behind this code, it’s unrelated to dry-v probably
Piotr Solnica
@solnic
Aug 01 2016 10:11
hanami/controller@8fa6938
hmm, it does say that for some reason it’s needed for dry-v, not sure why it was added though
Matt Patterson
@fidothe
Aug 01 2016 10:12

I'm guessing that it's

The input can include values that are strings, hashes or arrays

from http://dry-rb.org/gems/dry-validation/forms/

Piotr Solnica
@solnic
Aug 01 2016 10:13
yeah but that’s for coercion, an uploaded file won’t cause any issues
you don’t coerce it
Matt Patterson
@fidothe
Aug 01 2016 10:13
sounds like I can open a PR that addresses the issue in Hanami without needing to open an issue here, which is cool
Piotr Solnica
@solnic
Aug 01 2016 10:14
this stringify! should be removed, it’s not needed
Matt Patterson
@fidothe
Aug 01 2016 10:14
even easier, a PR that'll just delete code :-)
Nikita Shilnikov
@flash-gordon
Aug 01 2016 10:14
@solnic I believe it's related to calling actions in specs
Piotr Solnica
@solnic
Aug 01 2016 10:15
@flash-gordon maybe it’s an issue with coercion where an already coerced data was passed in
so ie Types::Form::Date will choke on it
Nikita Shilnikov
@flash-gordon
Aug 01 2016 10:15
yeah, I think so
Piotr Solnica
@solnic
Aug 01 2016 10:15
but this feels like a really bad workaround for an issue with testing
if it’s a testing-related issue, it should be fixed in some test-aid API, not the main run-time code
@fidothe pls open an issue/pr in hanami-controller and CC me
Fran Worley
@fran-worley
Aug 01 2016 10:16
Is it worth raising it with @jodosha to see what the method is really there for?
Piotr Solnica
@solnic
Aug 01 2016 10:16
I’m 99.9% sure it’s because of testing with data that’s already coerced
Matt Patterson
@fidothe
Aug 01 2016 10:17
@solnic we already did: hanami/controller#166
Piotr Solnica
@solnic
Aug 01 2016 10:18
I also remember Luca mentioning that some middlewares may already coerce something, ie that hanami adds already coerced params and passes them to an action for stuff like /foo/:id where id becomes an int
@fidothe I guess a quick workaround for now would be to skip #to_s for file data
it’s a Tempfile IIRC
but overall it’d be brittle, so I’d like to see how we can solve it better but first I gotta understand exactly why it was added
Matt Patterson
@fidothe
Aug 01 2016 10:19
yeah, that's the WIP fix I have
Piotr Solnica
@solnic
Aug 01 2016 10:20
FWIW I think hanami should apply schema automatically and pass result to action, not raw params
this way it would coerce everything in the schema
and stringify! could be removed
and issue with stuff like :id being already an int wouldn’t be an issue since schema would handle that
and people wouldn’t have to apply schemas manually
so basically params in an action would become dry-v result (probably wrapped by Hanami object)
Piotr Solnica
@solnic
Aug 01 2016 10:27
@fran-worley did you have a chance to experiment further with dry-logic’s new result AST?
Fran Worley
@fran-worley
Aug 01 2016 10:29
@solnic sadly no. Life got a little in the way. Are you planning on looking at it soon then?
Piotr Solnica
@solnic
Aug 01 2016 10:30
@fran-worley I do, we have a couple of bug reports that I’m not willing to address until we have a better result AST in place…
I already spent enough time applying ugly fixes for some less-common cases, and they would’ve been much simpler if the result ast was better
so my plan is to design this AST first with some specs in dry-v against a hard-coded ast as test fixtures, then we could think about how to tweak dry-logic to produce it
another thing is to tweak dry-logic so that it can produce failures exclusively and skip result processing for successfuly applied predicates
as that will make dry-v ultimately faster than anything else :laughing:
Fran Worley
@fran-worley
Aug 01 2016 10:48
Say design is a good start. There is an issue and PR in dry logic that is pretty much where we left off. I can put some time into this is afternoon if you like?
Piotr Solnica
@solnic
Aug 01 2016 10:49
oh sure, feel free to experiment, starting with a list of few result asts that we have now and looking how it could be simplified will be a great start