Sha256: a921ac5fbde983dad0e831337fd68fdfe65c8896698c606ece76f759a2f066bf

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module JSI
  module Schema::Validation::PropertyNames
    # @private
    def internal_validate_propertyNames(result_builder)
      if keyword?('propertyNames')
        # The value of "propertyNames" MUST be a valid JSON Schema.
        #
        # If the instance is an object, this keyword validates if every property name in the instance
        # validates against the provided schema. Note the property name that the schema is testing will
        # always be a string.
        if result_builder.instance.respond_to?(:to_hash)
          results = {}
          result_builder.instance.keys.each do |property_name|
            results[property_name] = subschema(['propertyNames']).internal_validate_instance(
              Ptr[],
              property_name,
              validate_only: result_builder.validate_only,
            )
          end
          result_builder.validate(
            results.values.all?(&:valid?),
            'instance object property names are not all valid against `propertyNames` schema value',
            keyword: 'propertyNames',
            results: results.values,
          )
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
jsi-0.8.1 lib/jsi/schema/validation/property_names.rb
jsi-0.8.0 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.4 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.5 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.6 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.7 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.8 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.8.pre.maruku lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.7.pre.rdiscount lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.6.pre.redcarpet lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.5.pre.kramdown lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.4.pre.commonmarker lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.0.pre.commonmarker lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.0.pre.kramdown lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.0.pre.redcarpet lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.0.pre.rdiscount lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.0.pre.maruku lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.3 lib/jsi/schema/validation/property_names.rb
jsi-dev-0.0.2 lib/jsi/schema/validation/property_names.rb
jsi-0.7.0 lib/jsi/schema/validation/property_names.rb