class Snapi::JsonValidator
Provide an object to validate JSON with a =~ method that mirrors Regexp.=~. The existing validation code relies on the fact that Regexp.=~ will return the index for which the string matches the regex. We return 0 if the JSON is parsable, since the JSON string will always start at index 0.
Public Class Methods
=~(obj)
click to toggle source
# File lib/snapi/validator.rb, line 131 def self.=~(obj) begin JSON.parse(obj) 0 rescue nil end end