Sha256: 43f43bc738f65026fac88e7b8e0837cf24731427a8a22ba21ada0027bfbaf1c7
Contents?: true
Size: 969 Bytes
Versions: 19
Compression:
Stored size: 969 Bytes
Contents
RSpec.describe Dry::Validation::Schema, 'dynamic predicate args' do context 'with base rules' do subject(:schema) do Dry::Validation.Schema do configure do def data %w(a b c) end end required(:letter).filled(included_in?: data) end end it 'evaluates predicate arguments' do expect(schema.(letter: 'a')).to be_success expect(schema.(letter: 'f')).to be_failure end end context 'with high-level rules' do subject(:schema) do Dry::Validation.Schema do configure do def data %w(a b c) end end required(:letter).filled(:str?) rule(valid_letter: [:letter]) do |letter| letter.included_in?(data) end end end it 'evaluates predicate arguments' do expect(schema.(letter: 'a')).to be_success expect(schema.(letter: 'f')).to be_failure end end end
Version data entries
19 entries across 19 versions & 1 rubygems