Sha256: b95ad963ffa31ce0b3553e50c0c657db3d48daae56744c0ed8d7b4c33d437aa2
Contents?: true
Size: 761 Bytes
Versions: 18
Compression:
Stored size: 761 Bytes
Contents
RSpec.describe 'Reusing schemas' do subject(:schema) do Dry::Validation.Schema do required(:city).filled required(:location).schema(LocationSchema) end end before do LocationSchema = Dry::Validation.Schema do configure { config.input_processor = :form } required(:lat).filled(:float?) required(:lng).filled(: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
18 entries across 18 versions & 1 rubygems