Sha256: 06914794c4b32c0bff1162d77a9d6eb60eb1b8f1ff2719cf4341f6e7e9e83434
Contents?: true
Size: 788 Bytes
Versions: 5
Compression:
Stored size: 788 Bytes
Contents
RSpec.describe 'Macros #maybe' do describe 'with no args' do subject(:schema) do Dry::Validation.Schema do key(:email).maybe end end it 'generates none? | filled? rule' do expect(schema.(email: nil).messages).to be_empty expect(schema.(email: 'jane@doe').messages).to be_empty end end describe 'with a predicate with args' do subject(:schema) do Dry::Validation.Schema do key(:name).maybe(min_size?: 3) end end it 'generates none? | (filled? & min_size?) rule' do expect(schema.(name: nil).messages).to be_empty expect(schema.(name: 'jane').messages).to be_empty expect(schema.(name: 'xy').messages).to eql( name: ['size cannot be less than 3'] ) end end end
Version data entries
5 entries across 5 versions & 1 rubygems