Sha256: 3a05ff4d1ea6e40f3bc22d83897345a91d0c655cd4792997138a69d37b594b8d

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

module Dry
  module Validation
    class Schema
      class Check < Value
        def class
          Check
        end

        def schema(other = nil, &block)
          schema = Schema.create_class(self, other, &block)

          if other
            schema.config.input_processor = other.class.config.input_processor
          end

          hash?.and(create_rule([:check, [name, schema.to_ast], [path]]))
        end

        private

        def method_missing(meth, *meth_args)
          vals, args = meth_args.partition { |arg| arg.class < DSL }

          keys = [name, *vals.map(&:name)]
          predicate = [:predicate, [meth, args]]

          rule = create_rule([:check, [name, predicate, keys]])
          add_rule(rule)
          rule
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-validation-0.7.4 lib/dry/validation/schema/check.rb
dry-validation-0.7.3 lib/dry/validation/schema/check.rb
dry-validation-0.7.2 lib/dry/validation/schema/check.rb