Sha256: d1dbf27a799ea865eb46cf95226d4c903db33b140618bf4ce3968b5914985f5b

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
module JSONSchemer
  module Draft202012
    module Vocab
      module MetaData
        class ReadOnly < Keyword
          def error(formatted_instance_location:, **)
            "value at #{formatted_instance_location} is `readOnly`"
          end

          def validate(instance, instance_location, keyword_location, context)
            valid = parsed != true || !context.access_mode || context.access_mode == 'read'
            result(instance, instance_location, keyword_location, valid, :annotation => value)
          end
        end

        class WriteOnly < Keyword
          def error(formatted_instance_location:, **)
            "value at #{formatted_instance_location} is `writeOnly`"
          end

          def validate(instance, instance_location, keyword_location, context)
            valid = parsed != true || !context.access_mode || context.access_mode == 'write'
            result(instance, instance_location, keyword_location, valid, :annotation => value)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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