Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
this would be less trivial to implement though :)
Andy Holland
@AMHOL
As opposed to:
key(:address).hash? do |address|
  address.key(:age).int? & address.key(:age).gt?(18)
end
?
Piotr Solnica
@solnic
not exactly
type check is kind-of special
first of all you specify the expection for the type so we can infer coercion logic from it
secondly it’s the very first check that needs to be done before we can do anything else with the value
Andy Holland
@AMHOL
Ahh OK
Piotr Solnica
@solnic
so having it outside of the block would make sense
I dunno, will see, not gonna do that now, just wondering
Andy Holland
@AMHOL
So the predicate would be a pre-requisite to the validations running inside of the block?
Piotr Solnica
@solnic
yes
Andy Holland
@AMHOL
That makes sense :+1:
Piotr Solnica
@solnic
I just added support for passing blocks to predicate checks, which does the very same thing, but for type-check you get one more level of nesting
hence my thought about moving it to the outer block
Andy Holland
@AMHOL
Yep, that works for me
Piotr Solnica
@solnic
you can do value.int? & value.gt?(18) and the equivalent of this is using a block like this; value.int? { value.gt?(18) }
in general a block == AND
Andy Holland
@AMHOL
So it's like a normal AND where the right only evaluates if the left passes?
Piotr Solnica
@solnic
yes
Andy Holland
@AMHOL
:+1:
Andy Holland
@AMHOL
@solnic WDYT to removing the message processor from dry-validation?
Piotr Solnica
@solnic
@AMHOL dunno yet what to do with it tbh
Andy Holland
@AMHOL
@solnic I'll push what I've got so far, see what you think
Piotr Solnica
@solnic
@AMHOL sure
Andy Holland
@AMHOL
dryrb/dry-validation@cbc17e5
So the idea is that we can have a dry-validation-i18n gem for error messages
BTW, now I've got to grips with it a lot more, you've done a fantastic job so far
Piotr Solnica
@solnic
@AMHOL no idea what "to grip" means :D
Andy Holland
@AMHOL
:laughing: idioms
Piotr Solnica
@solnic
dammit mate
;)
Andy Holland
@AMHOL
To get to grips = to get a better understanding :)
So if I get to grips with {something}, I have a better understanding of {something} than I did before
Piotr Solnica
@solnic
Oh ok :) it is really simple piece of code tbh. Ast with visitor pattern is really simple. Probably not popular but that is ok
Aaahhh good
Andy Holland
@AMHOL
Yeah, perhaps to you ;)
Ast is complicated stuff
Piotr Solnica
@solnic
I thought so too when I saw it for the first time
Andy Holland
@AMHOL
I think it's just unfamiliar territory, from what I've seen you don't tend to touch AST until you start looking at compilers and sth?
Piotr Solnica
@solnic
Yeah only compilers deal with then
Them even
Krzysztof Wawer
@wafcio
How in dry-validation can I construct rule for attribute which is optional but if exists then it should be in specific format ? I am trying to do it in this way: id.nil? | (id.str? & id.format?(/.../)) but I receive NoMethodError: undefined method `to_ary' for true:TrueClass
Piotr Solnica
@solnic
@wafcio id.filled? & id.format?(/.../) should suffice
Although your example should work too
So pls report an issue
Krzysztof Wawer
@wafcio
I used str? because I checked examples: a) without id b) with number id - incorrect c) with id as uuid (text) - correct
Krzysztof Wawer
@wafcio
issue added dryrb/dry-validation#13
Piotr Solnica
@solnic
@wafcio thanks. I'll fix that
Krzysztof Wawer
@wafcio
ok thanks, I will bypass this problem with write own predicate