psantos10/Validation

View on GitHub
lib/resize/rules/is_json.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'json'

module Resize
  module Validation
    module Rules
      module IsJson
        private
          def is_valid?(input)
            begin
              JSON.parse(input)
              return true
            rescue JSON::ParserError
              return false
            end
          end
      end
    end
  end
end