Sha256: ca119797b664db632684b4cf47a8df3c97bc691f3582e4bac231067357118517

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

RSpec.describe 'Schema::Form / Default key behavior' do
  subject(:validate) { schema.new }

  let(:schema) do
    Class.new(Dry::Validation::Schema::Form) do
      key(:name)
      key(:age, &:int?)
      optional(:address)
    end
  end

  it 'applies filled? predicate by default' do
    expect(validate.('name' => 'jane', 'age' => '21').params).to eql(
      name: 'jane', age: 21
    )
  end

  it 'applies filled? predicate by default to optional key' do
    expect(validate.('name' => 'jane', 'age' => '21', 'address' => 'Earth').params).to eql(
      name: 'jane', age: 21, address: 'Earth'
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-validation-0.6.0 spec/integration/schema/default_key_behavior_spec.rb