Sha256: a11c0ff6f035141ce38f79a5a220cc0c1d2ffaa37f9a6e8d3d5bc57947fbf3c4

Contents?: true

Size: 717 Bytes

Versions: 5

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true
module JSONSchemer
  module Draft202012
    module Vocab
      module FormatAssertion
        class Format < Keyword
          def error(formatted_instance_location:, **)
            "value at #{formatted_instance_location} does not match format: #{value}"
          end

          def parse
            root.format && root.fetch_format(value) { raise UnknownFormat, value }
          end

          def validate(instance, instance_location, keyword_location, _context)
            valid = parsed == false || parsed.call(instance, value)
            result(instance, instance_location, keyword_location, valid, :annotation => value)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_schemer-2.3.0 lib/json_schemer/draft202012/vocab/format_assertion.rb
json_schemer-2.2.1 lib/json_schemer/draft202012/vocab/format_assertion.rb
json_schemer-2.2.0 lib/json_schemer/draft202012/vocab/format_assertion.rb
json_schemer-2.1.1 lib/json_schemer/draft202012/vocab/format_assertion.rb
json_schemer-2.1.0 lib/json_schemer/draft202012/vocab/format_assertion.rb