Sha256: a1fbffa934b662dbb2d9390aa977c308537b4fa79f2eb3cce8db2be9fe788fe4

Contents?: true

Size: 694 Bytes

Versions: 5

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true
module JSONSchemer
  module Draft202012
    module Vocab
      module FormatAnnotation
        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, false)
          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_annotation.rb
json_schemer-2.2.1 lib/json_schemer/draft202012/vocab/format_annotation.rb
json_schemer-2.2.0 lib/json_schemer/draft202012/vocab/format_annotation.rb
json_schemer-2.1.1 lib/json_schemer/draft202012/vocab/format_annotation.rb
json_schemer-2.1.0 lib/json_schemer/draft202012/vocab/format_annotation.rb