Sha256: 37dcdc344afebdb0c2a20f2a95324c686b74407a1dacd8f3779a447fd47a9e54
Contents?: true
Size: 846 Bytes
Versions: 12
Compression:
Stored size: 846 Bytes
Contents
RSpec.describe 'Schema / Injecting Rules' do subject(:schema) do Dry::Validation.Schema(rules: other.class.rules) do required(:email).maybe rule(:email) { value(:login).true? > value(:email).filled? } end end let(:other) do Dry::Validation.Schema do required(: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 it 'keeps the original schema rules intact' do expect(other.class.rules.size).to eq(1) schema.(login: true, email: 'jane@doe') expect(other.class.rules.size).to eq(1) end end
Version data entries
12 entries across 12 versions & 1 rubygems