Exception: Meta::JsonSchema::ValidationErrors
- Inherits:
-
StandardError
- Object
- StandardError
- Meta::JsonSchema::ValidationErrors
- Defined in:
- lib/meta/json_schema/support/errors.rb
Direct Known Subclasses
Errors::ParameterInvalid, Errors::RenderingInvalid, ValidationError
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(errors, message = nil) ⇒ ValidationErrors
constructor
A new instance of ValidationErrors.
- #prepend_root(root) ⇒ Object
Constructor Details
#initialize(errors, message = nil) ⇒ ValidationErrors
Returns a new instance of ValidationErrors.
8 9 10 11 12 13 |
# File 'lib/meta/json_schema/support/errors.rb', line 8 def initialize(errors, = nil) raise ArgumentError, '参数 errors 应传递一个 Hash' unless errors.is_a?(Hash) super() @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/meta/json_schema/support/errors.rb', line 6 def errors @errors end |
Instance Method Details
#prepend_root(root) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/meta/json_schema/support/errors.rb', line 15 def prepend_root(root) errors_prepend_root = errors.transform_keys do |name| return name.to_s if root.empty? path = name[0] == '[' ? "#{root}#{name}" : "#{root}.#{name}" path = path[1..] if path[0] == '.' path = path[0..-2] if path[-1] == '.' path end ValidationErrors.new(errors_prepend_root) end |