Module: Kwalify::ErrorHelper
Class Method Summary collapse
- ._build_message(message_key, val, args) ⇒ Object
- .validate_error(error_symbol, rule, path, val, args = nil) ⇒ Object
Instance Method Summary collapse
-
#assert_error(message = "") ⇒ Object
module_function.
- #schema_error(error_symbol, rule, path, val, args = nil) ⇒ Object
Class Method Details
._build_message(message_key, val, args) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/kwalify/errors.rb', line 114 def (, val, args) msg = Kwalify.msg() assert_error("message_key=#{.inspect}") unless msg msg = msg % args if args msg = "'#{val.to_s.gsub(/\n/, '\n')}': #{msg}" if !val.nil? && Types.scalar?(val) return msg; end |
.validate_error(error_symbol, rule, path, val, args = nil) ⇒ Object
101 102 103 104 105 |
# File 'lib/kwalify/errors.rb', line 101 def validate_error(error_symbol, rule, path, val, args=nil) msg = (error_symbol, val, args); path = '/'+path.join('/') if path.is_a?(Array) return ValidationError.new(msg, path, val, rule, error_symbol) end |
Instance Method Details
#assert_error(message = "") ⇒ Object
module_function
97 98 99 |
# File 'lib/kwalify/errors.rb', line 97 def assert_error(="") raise AssertionError.new() end |
#schema_error(error_symbol, rule, path, val, args = nil) ⇒ Object
108 109 110 111 112 |
# File 'lib/kwalify/errors.rb', line 108 def schema_error(error_symbol, rule, path, val, args=nil) msg = (error_symbol, val, args); path = '/'+path.join('/') if path.is_a?(Array) return SchemaError.new(msg, path, val, rule, error_symbol) end |