Sha256: a9fb8baade1cce9795fc47307ddffd047aa43208727d7700685ebbd8507d8fef

Contents?: true

Size: 402 Bytes

Versions: 2

Compression:

Stored size: 402 Bytes

Contents

module ObjectValidator
  class Errors
    attr_accessor :all

    def initialize
      @all = {}
      @full_messages = []
    end

    def add(name, msg)
      (@all[name] ||= []) << msg
    end

    def full_messages
      @all.map do |error|
        attr, errors = *error
        errors.each { |e| @full_messages << "#{attr.to_s.capitalize} #{e}." }
      end
      @full_messages
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
object_validator-0.1.1 lib/object_validator/errors.rb
object_validator-0.1.0 lib/object_validator/errors.rb