Sha256: 9082d4f9f52e31e82c4c5616d79cc871a66a79deb984ad1eb5be95b16ec094c1
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require 'media_types/scheme/errors' module MediaTypes class Scheme class MissingValidation def validate!(_output, options, context:, **_opts) # Check that no unknown keys are present return true unless options.strict raise_strict!(key: context.key, strict_keys: context.rules, backtrace: options.backtrace, found: options.scoped_output) end def raise_strict!(key:, backtrace:, strict_keys:, found:) raise StrictValidationError, format( "Unknown key %<key>s in data.\n" \ "\tFound at: %<backtrace>s\n" \ "\tExpected:\n\n" \ "%<strict_keys>s\n\n" \ "\tBut I Found:\n\n" \ '%<found>s', key: key.inspect, backtrace: backtrace.join('->'), strict_keys: strict_keys.keys, found: (found.is_a? Hash) ? found.keys : found.class.name ) end def inspect '((raise when strict))' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
media_types-2.0.0 | lib/media_types/scheme/missing_validation.rb |