These are chat archives for dry-rb/chat

9th
Nov 2016
Ramon Tayag
@ramontayag
Nov 09 2016 00:46
@solnic I want to add something to the readme about constructor_type to the readme. As far as I can see, there are these types: :strict, :permissive, and :schema. I guess you meant that it is :strict by default, but what is the difference with the latter two?
Let me check dry-types first
Ramon Tayag
@ramontayag
Nov 09 2016 00:52
There are certain schemas in the codebase of dry-struct that can't be found in http://dry-rb.org/gems/dry-types/hash-schemas/ that
Ramon Tayag
@ramontayag
Nov 09 2016 02:03
For dry-struct, what is the recommended way of creating setters?
Ramon Tayag
@ramontayag
Nov 09 2016 06:31
@jdickey cool :)
Piotr Solnica
@solnic
Nov 09 2016 10:35
@ramontayag the recommend way is to not use setters :)
Piotr Solnica
@solnic
Nov 09 2016 10:58
@ramontayag there’s a WIP PR which will add more docs about it dry-rb/dry-rb.org#104
Ramon Tayag
@ramontayag
Nov 09 2016 12:37
@solnic ok cool I can discard my changes then! How would you go about replacing virtus with the dry gems? Would you recommend doing so?
Hannes Nevalainen
@kwando
Nov 09 2016 14:15
dry-validation is freaking awesome! xD
Steve
@dnd
Nov 09 2016 14:17
@timriley, @solnic I posted my question from the other day on the discussion board, but haven't gotten any traction on it. Any idea if there is a way to easily do this currently, or where I could start looking to make it possible? https://discuss.dry-rb.org/t/get-keys-instead-of-sentences-for-validation-errors/150/1
Piotr Solnica
@solnic
Nov 09 2016 14:18
@dnd hey, I’ll be replying to posts later today. I’ve been busy with rom-sql new release lately
Steve
@dnd
Nov 09 2016 14:18
cool, thanks
Lucas Hosseini
@beauby
Nov 09 2016 20:11
Any specific reason why no built-in predicates on min/max length of strings in dry-validation?
Fran Worley
@fran-worley
Nov 09 2016 20:13
@beauby there are built in predicates. min_size? And max_size? Work on anything that responds to size.
Lucas Hosseini
@beauby
Nov 09 2016 20:14
Hmm some examples seem to imply that the _size? predicates work on string, but the doc says it is valid for arrays only
Fran Worley
@fran-worley
Nov 09 2016 20:14
Take a look here to see all built in predicates and the code behind them: https://github.com/dry-rb/dry-logic/blob/master/lib/dry/logic/predicates.rb
Lucas Hosseini
@beauby
Nov 09 2016 20:14
@fran-worley Right – yeah, that was my source of information, but as you can see, it explicitly talks only about arrays
I’ll issue a PR
Fran Worley
@fran-worley
Nov 09 2016 20:16
Good spot on the docs and thanks in advance for the PR.
Piotr Solnica
@solnic
Nov 09 2016 20:21
@kwando haha, is it? :D
@dnd re virtus, you need dry-struct + attr_writer
then, assuming your virtus models are relatively simple, this should be easy
just remember that dry-struct uses types that don't match virtus coercion logic
so ie if you use input from http params, you would have to use Types::Form::* types for your attributes
Steve
@dnd
Nov 09 2016 20:35
@solnic I think someone else was looking for that information.
I think @ramontayag was?
I'm just here for the dry-validation errors question. :)
Piotr Solnica
@solnic
Nov 09 2016 20:37
ugh sorry about that
@ramontayag see above re virtus ^^