Sha256: af152ef736d166c28f279c447eacab21c72c94adbb6de4ea8b221ad6ab49a1e3
Contents?: true
Size: 700 Bytes
Versions: 5
Compression:
Stored size: 700 Bytes
Contents
RSpec.describe Dry::Validation::Schema do describe 'defining schema with optional keys' do subject(:schema) do Dry::Validation.Schema do optional(:email) { |email| email.filled? } key(:address) do key(:city, &:filled?) key(:street, &:filled?) optional(:phone_number) do none? | str? end end end end describe '#call' do it 'skips rules when key is not present' do expect(schema.(address: { city: 'NYC', street: 'Street 1/2' })).to be_success end it 'applies rules when key is present' do expect(schema.(email: '')).to_not be_success end end end end
Version data entries
5 entries across 5 versions & 1 rubygems