Sha256: 38ea028298767f0a59a850c613d9aa503b5154a5e0828e4f0958dc073ab6ec16

Contents?: true

Size: 1.24 KB

Versions: 19

Compression:

Stored size: 1.24 KB

Contents

RSpec.describe Schema::Key do
  include_context 'predicate helper'

  let(:registry) { PredicateRegistry.new(predicates) }

  describe '#str?' do
    subject(:user) { Schema::Key[:user, registry: registry] }

    it 'returns a key rule' do
      expect(user.str?.to_ast).to eql(
        [:rule, [:user, [:key, [:user, [:predicate, [:str?, [[:input, Undefined]]]]]]]]
      )
    end

    it 'returns a key rule & disjunction rule created within the block' do
      user.hash? do
        required(:email) { none? | filled? }
      end

      expect(user.to_ast).to eql(
        [:key, [:user, [:rule, [:user,
          [:and, [
            [:rule, [:user, [:predicate, [:hash?, [[:input, Undefined]]]]]],
            [:rule, [:user, [:key, [:user, [:rule, [:email,
              [:and, [
                [:rule, [:email, [:predicate, [:key?, [[:name, :email], [:input, Undefined]]]]]],
                [:rule, [:user, [:rule, [:email,
                  [:or, [
                    [:rule, [:email, [:key, [:email, [:predicate, [:none?, [[:input, Undefined]]]]]]]],
                    [:rule, [:email, [:key, [:email, [:predicate, [:filled?, [[:input, Undefined]]]]]]]]
                  ]]]]]]
              ]]]]]]]
            ]]]
        ]]]]
      )
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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