Exception: PgVerify::Model::Validation::ValidationError

Inherits:
Core::Error
  • Object
show all
Defined in:
lib/pg-verify/model/validation/errors.rb

Instance Method Summary collapse

Methods inherited from Core::Error

#to_formatted

Constructor Details

#initialize(model, errors) ⇒ ValidationError

Returns a new instance of ValidationError.



6
7
8
# File 'lib/pg-verify/model/validation/errors.rb', line 6

def initialize(model, errors)
    @model, @errors = model, errors
end

Instance Method Details

#formattedObject



10
11
12
13
14
15
16
17
18
# File 'lib/pg-verify/model/validation/errors.rb', line 10

def formatted()
    title = "There are #{@errors.length} errors for model #{@model.name}"

    summary = @errors.map{ |e| e.formatted.first }
    summary = summary.each_with_index.map { |e, i| "#{i + 1}: #{e}" }.join("\n")

    body = @errors.map(&:to_formatted).join("\n")
    return title, "#{summary}\n\n#{body}"
end