class HecksPlugins::JSONValidator::MessageParser
Turn the json-schema messages into easy to understand errors for the user
Attributes
error[R]
field_name[R]
fragment[R]
match[R]
matcher[R]
message[R]
Public Class Methods
new(matcher:, error:)
click to toggle source
# File lib/parsers/message_parser.rb, line 7 def initialize(matcher:, error:) @matcher = matcher @error = error @match = error[:message].match(matcher[:regex]) @fragment = error[:fragment].gsub('#/', '') if fragment == '' @fragment = nil else @fragment = fragment.to_sym end end
Public Instance Methods
call()
click to toggle source
# File lib/parsers/message_parser.rb, line 20 def call parse_match self end
Private Instance Methods
parse_match()
click to toggle source
# File lib/parsers/message_parser.rb, line 29 def parse_match return unless match @message = matcher[:message] @message = message % match[2..-1] if match.length > 2 @field_name = match[1].to_sym end