Class: NForm::ValidationError
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #error_messages ⇒ Object
-
#initialize(errors = {}) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #message ⇒ Object
Constructor Details
#initialize(errors = {}) ⇒ ValidationError
Returns a new instance of ValidationError.
30 31 32 |
# File 'lib/nform/form.rb', line 30 def initialize(errors={}) @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
29 30 31 |
# File 'lib/nform/form.rb', line 29 def errors @errors end |
Instance Method Details
#error_messages ⇒ Object
38 39 40 41 42 |
# File 'lib/nform/form.rb', line 38 def if errors.any? errors.map{|k,v| "#{k.to_s.humanize}: #{v}"}.join("\n") end end |
#message ⇒ Object
34 35 36 |
# File 'lib/nform/form.rb', line 34 def "\nPlease correct the following errors:\n#{error_messages}" end |