Exception: Gourami::ValidationError
- Defined in:
- lib/gourami/validation_error.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
!@attribute [r] errors @return [Hash<Symbol, Array>].
-
#resource_errors ⇒ Object
readonly
!@attribute [r] resource_errors @return [Hash<Symbol, Hash<Symbol, Hash<Symbol, Array>>>].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(errors, resource_errors = {}) ⇒ ValidationError
constructor
Initialize the Gourami::ValidationError.
- #message ⇒ Object
Constructor Details
#initialize(errors, resource_errors = {}) ⇒ ValidationError
Initialize the Gourami::ValidationError.
36 37 38 39 40 41 |
# File 'lib/gourami/validation_error.rb', line 36 def initialize(errors, resource_errors = {}) @resource_errors = resource_errors @errors = errors super() end |
Instance Attribute Details
#errors ⇒ Object (readonly)
!@attribute [r] errors
@return [Hash<Symbol, Array>]
26 27 28 |
# File 'lib/gourami/validation_error.rb', line 26 def errors @errors end |
#resource_errors ⇒ Object (readonly)
!@attribute [r] resource_errors
@return [Hash<Symbol, Hash<Symbol, Hash<Symbol, Array>>>]
30 31 32 |
# File 'lib/gourami/validation_error.rb', line 30 def resource_errors @resource_errors end |
Class Method Details
.stringify_errors(errors) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/gourami/validation_error.rb', line 4 def self.stringify_errors(errors) [].tap do |array| errors.each do |field, error| array.push("#{field}: #{error}") end end end |
.stringify_resource_errors(resource_errors) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gourami/validation_error.rb', line 12 def self.stringify_resource_errors(resource_errors) [].tap do |array| resource_errors.each do |resource_namespace, resource_namespace_errors| resource_namespace_errors.each do |resource_uid, resource_uid_errors| resource_uid_errors.each do |attribute_name, error| array.push("#{resource_namespace}:#{resource_uid}:#{attribute_name}: #{error}") end end end end end |
Instance Method Details
#message ⇒ Object
43 44 45 |
# File 'lib/gourami/validation_error.rb', line 43 def @message ||= stringify_all_errors end |