Sha256: 27276fcbcea67ddd968b49ed1095714cc5f26d26641bff903cd9e8ac22b184eb

Contents?: true

Size: 1.05 KB

Versions: 26

Compression:

Stored size: 1.05 KB

Contents

RSpec.describe Dry::Validation::Schema, 'setting input processor in schema' do
  subject(:schema) do
    Dry::Validation.Schema do
      configure do
        config.input_processor = :sanitizer
      end

      required(:email).filled

      required(:age).maybe(:int?, gt?: 18)

      required(:address).schema do
        required(:city).filled
        required(:street).filled
      end

      required(:phone_numbers).each do
        required(:prefix).filled
        required(:value).filled
      end
    end
  end

  it 'rejects unspecified keys' do
    result = schema.(
      email: 'jane@doe',
      age: 19,
      such: 'key',
      address: { city: 'NYC', street: 'Street', wow: 'bad' },
      phone_numbers: [
        { prefix: '48', value: '123' },
        { lol: '!!', prefix: '1', value: '312' }
      ]
    )

    expect(result.output).to eql(
      email: 'jane@doe',
      age: 19,
      address: { city: 'NYC', street: 'Street' },
      phone_numbers: [
        { prefix: '48', value: '123' },
        { prefix: '1', value: '312' }
      ]
    )
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dry-validation-0.13.3 spec/integration/schema/input_processor_spec.rb
dry-validation-0.13.2 spec/integration/schema/input_processor_spec.rb
dry-validation-0.13.1 spec/integration/schema/input_processor_spec.rb
dry-validation-0.11.2 spec/integration/schema/input_processor_spec.rb
dry-validation-0.12.3 spec/integration/schema/input_processor_spec.rb
dry-validation-0.13.0 spec/integration/schema/input_processor_spec.rb
dry-validation-0.12.2 spec/integration/schema/input_processor_spec.rb
dry-validation-0.12.1 spec/integration/schema/input_processor_spec.rb
dry-validation-0.12.0 spec/integration/schema/input_processor_spec.rb
dry-validation-0.11.1 spec/integration/schema/input_processor_spec.rb
dry-validation-0.11.0 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.7 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.6 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.5 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.4 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.3 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.2 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.1 spec/integration/schema/input_processor_spec.rb
dry-validation-0.10.0 spec/integration/schema/input_processor_spec.rb
dry-validation-0.9.5 spec/integration/schema/input_processor_spec.rb