Sha256: 5be4aca4e0c577f81eab453343656773887f09062dd27e9aea4ea2233b4b1bea

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

module Dry
  module Validation
    class Error
      class Set
        include Enumerable

        attr_reader :errors

        def initialize
          @errors = []
        end

        def each(&block)
          errors.each(&block)
        end

        def empty?
          errors.empty?
        end

        def <<(error)
          errors << error
        end

        def to_ary
          errors.map { |error| error.to_ary }
        end
        alias_method :to_a, :to_ary
      end

      attr_reader :result

      def initialize(result)
        @result = result
      end

      def to_ary
        [:error, result.to_ary]
      end
      alias_method :to_a, :to_ary
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-0.2.0 lib/dry/validation/error.rb
dry-validation-0.1.0 lib/dry/validation/error.rb