Sha256: d74fd11fbe0d956d8a2d3262dd419d9cdcbc749884e3997b962c57a8b413fbc7

Contents?: true

Size: 451 Bytes

Versions: 2

Compression:

Stored size: 451 Bytes

Contents

module Dry
  module Validation
    class Schema
      class Rule
        attr_reader :name, :node

        def initialize(node)
          @node = node
        end

        def to_ary
          node
        end
        alias_method :to_a, :to_ary

        def &(other)
          self.class.new([:and, [node, other.to_ary]])
        end

        def |(other)
          self.class.new([:or, [node, other.to_ary]])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-0.3.1 lib/dry/validation/schema/rule.rb
dry-validation-0.3.0 lib/dry/validation/schema/rule.rb