Exception: PgVerify::Model::Validation::ValidationError
- Inherits:
-
Core::Error
- Object
- StandardError
- Core::Error
- PgVerify::Model::Validation::ValidationError
- Defined in:
- lib/pg-verify/model/validation/errors.rb
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(model, errors) ⇒ ValidationError
constructor
A new instance of ValidationError.
Methods inherited from Core::Error
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
#formatted ⇒ Object
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 |