Sha256: f4387376ca8b85f20fbbac4bb259b1dc7d8574a27d21bf2f79bef34c190c0904

Contents?: true

Size: 891 Bytes

Versions: 19

Compression:

Stored size: 891 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, [[path], schema.to_ast]]))
        end

        private

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

          keys = [path, vals.map(&:path)].reject(&:empty?)

          registry.ensure_valid_predicate(meth, args.size + keys.size, schema_class)
          predicate = predicate(meth, args)

          rule = create_rule([:check, [keys.reverse, predicate]], name)

          add_rule(rule)
          rule
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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