Sha256: 7624ec48f80cf8c3b9efdda55f4bbfa9b3fce477c8ac1de3e63f59eb841dae6e

Contents?: true

Size: 646 Bytes

Versions: 5

Compression:

Stored size: 646 Bytes

Contents

RSpec.describe 'Schema / Injecting Rules' do
  subject(:schema) do
    Dry::Validation.Schema(rules: other.class.rules) do
      key(:email).maybe

      rule(:email) { value(:login).true? > value(:email).filled? }
    end
  end

  let(:other) do
    Dry::Validation.Schema do
      key(:login) { |value| value.bool? }
    end
  end

  it 'appends rules from another schema' do
    expect(schema.(login: true, email: 'jane@doe')).to be_success
    expect(schema.(login: false, email: nil)).to be_success
    expect(schema.(login: true, email: nil)).to_not be_success
    expect(schema.(login: nil, email: 'jane@doe')).to_not be_success
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-validation-0.7.4 spec/integration/injecting_rules_spec.rb
dry-validation-0.7.3 spec/integration/injecting_rules_spec.rb
dry-validation-0.7.2 spec/integration/injecting_rules_spec.rb
dry-validation-0.7.1 spec/integration/injecting_rules_spec.rb
dry-validation-0.7.0 spec/integration/injecting_rules_spec.rb