Sha256: 3d74d98082bcba7c197985091a72aec25f66e68e622318f0c3f84eb60700652b
Contents?: true
Size: 722 Bytes
Versions: 26
Compression:
Stored size: 722 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? } required(:address).schema do required(:city, &:filled?) required(: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
26 entries across 26 versions & 1 rubygems