Sha256: 90e2b90d8c9711b054c2f7ddf0b4021db6df53eb069914e1cbaaac90bf8c41de
Contents?: true
Size: 747 Bytes
Versions: 5
Compression:
Stored size: 747 Bytes
Contents
RSpec.describe 'Reusing schemas' do subject(:schema) do Dry::Validation.Schema do key(:city).required key(:location).schema(LocationSchema) end end before do LocationSchema = Dry::Validation.Schema do configure { config.input_processor = :form } key(:lat).required(:float?) key(:lng).required(:float?) end end after do Object.send(:remove_const, :LocationSchema) end it 're-uses existing schema' do expect(schema.(city: 'NYC', location: { lat: 1.23, lng: 45.6 })).to be_success expect(schema.(city: 'NYC', location: { lat: nil, lng: '45.6' }).messages).to eql( location: { lat: ['must be filled'], lng: ['must be a float'] } ) end end
Version data entries
5 entries across 5 versions & 1 rubygems