These are chat archives for dry-rb/chat

15th
Dec 2015
Piotr Solnica
@solnic
Dec 15 2015 16:46
@wafcio so, what kind of issues did you have with dry-v?
Krzysztof Wawer
@wafcio
Dec 15 2015 16:46

so my opinion about dry-validation - it has freaky error format: sometime I see

errors = schema.call(email: 'jane@doe.org', age: 17).messages

puts errors.inspect
# { :age => [["age must be greater than 18"], 17] }

another time I see

errors = schema.call(email: nil, age: 19).messages

puts errors.inspect
# { :email => [["email must be filled", nil]] }

I caused that I droped dry-validation today.

Piotr Solnica
@solnic
Dec 15 2015 16:47
wow what happened with the formating here?
Krzysztof Wawer
@wafcio
Dec 15 2015 16:47
I have always problem with formatting in this strange style and strange new line keys
maybe I will back to dry-validation when I will have more time
Piotr Solnica
@solnic
Dec 15 2015 16:48
I’m not sure what the problem is, it gives you errors
Krzysztof Wawer
@wafcio
Dec 15 2015 16:48
I wanted use drop validation in API where I need return validation keys
and when I saw
[[„invalid”, nil]]
I said WHAT ???
invalid was my translation message
Piotr Solnica
@solnic
Dec 15 2015 16:49
so what’s the problem?
first array includes compiled error messages, the second argument is the original input value
Krzysztof Wawer
@wafcio
Dec 15 2015 16:50
and for this I must write own wrapper, and when I open README and saw that sometimes there is construction like
[[…, …], …]
I said not today
Piotr Solnica
@solnic
Dec 15 2015 16:51
what is your desired format?
error messages can be compiled to anything, I just used a simple hash for now as the default but it can be literally anything, it’s a pluggable “behavior” in dry-v
Krzysztof Wawer
@wafcio
Dec 15 2015 16:51
{ attribute: [error, error], attribute: [error, error]}
like it was in 0.1.0 version
Piotr Solnica
@solnic
Dec 15 2015 16:51
so you don’t like the fact you’ve got original value?
Krzysztof Wawer
@wafcio
Dec 15 2015 16:52
for now I have this requirement from frontend app
Piotr Solnica
@solnic
Dec 15 2015 16:52
I put it there because it’s useful for cases like each rule and figuring out the index of a given value when it comes from an array
displaying these errors is still pretty simple though, not sure why it has put you off :)
errors.each { |attribute, (messages, _)| … } or something
Krzysztof Wawer
@wafcio
Dec 15 2015 16:54
I don’t understand why there is two different format: { :age => [["age must be greater than 18"], 17] } and { :email => [["email must be filled", nil]] }
Piotr Solnica
@solnic
Dec 15 2015 16:54
two formats?
Krzysztof Wawer
@wafcio
Dec 15 2015 16:55
[[…], …] and [[…, …]]
Piotr Solnica
@solnic
Dec 15 2015 16:55
oh, now THAT seems like a bug :joy:
I will try to repro and fix
Krzysztof Wawer
@wafcio
Dec 15 2015 16:55
I read it from README file
maybe README is old
Piotr Solnica
@solnic
Dec 15 2015 16:56
maybe I made a mistake writing readme, that’s more likely :)
Krzysztof Wawer
@wafcio
Dec 15 2015 16:56
ok
Piotr Solnica
@solnic
Dec 15 2015 16:56
lemme see
Krzysztof Wawer
@wafcio
Dec 15 2015 16:56
so I will give chance dry-validation, again :)
Piotr Solnica
@solnic
Dec 15 2015 16:58
yeah, it’s a bug, I’ll fix it and push a release
Krzysztof Wawer
@wafcio
Dec 15 2015 16:58
I wanted switch to dry-validation in 0.1.0 version, but like I said some time aga in 0.1.0 we dry-validation didn’t have optional keys
ok
Piotr Solnica
@solnic
Dec 15 2015 17:03
uhm, it’s pretty messed up right now, no wonder it got you confused
I’ll try to fix it later today or tomorrow