Sha256: 7994e2e2e7b060ec5237344bc613bd26c49156ab782639350e5c1af5315ce49a
Contents?: true
Size: 603 Bytes
Versions: 19
Compression:
Stored size: 603 Bytes
Contents
RSpec.describe 'Check depending on nth element in an array' do subject(:schema) do Dry::Validation.Schema do required(:tags).each(:str?) rule(tags: [[:tags, 0]]) do |value| value.eql?('red') end end end it 'skips check when dependency failed' do expect(schema.(tags: 'oops')).to be_failure end it 'passes when check passes' do expect(schema.(tags: %w(red green blue))).to be_success end it 'fails when check fails' do expect(schema.(tags: %w(blue green red)).messages).to eql( tags: { 0 => ["must be equal to red"] } ) end end
Version data entries
19 entries across 19 versions & 1 rubygems