These are chat archives for dry-rb/chat

Apr 2018
Nikolai Budko
Apr 28 2018 13:48

Hi guys! I have a problem with dry-validations (0.11)

require 'dry-validation'

UserSchema = Dry::Validation.Schema do
  rule(value_filled: [:value1, :value2, :value3]) do |value1, value2, value3|
    value1.eql?('1') | value2.eql?('1') | value3.eql?('1')

  value1: '0',
  value2: '0',
  value3: '0'

# => "#<Dry::Validation::Result output={:value1=>\"0\", :value2=>\"0\", :value3=>\"0\"} errors={}>"

Why there are no errors for the schema? y rule is one of the fields must be filled with '1'

Nikolai Budko
Apr 28 2018 14:04

Oh, I'v got it. I need to defined this properies as optional

But I think it's a little bit redundant..

Also if I define three optional properties, than I will get a strange error:
 => "#<Dry::Validation::Result output={:value1=>\"0\", :value2=>\"0\", :value3=>\"0\"} errors={:some_filled=>[\"must be equal to 1 or must be equal to 1\"]}>"