Sha256: add926da7bb81534e62a9ec1b349cde18b3ce312b9b497b60f2316f6921b6084

Contents?: true

Size: 722 Bytes

Versions: 10

Compression:

Stored size: 722 Bytes

Contents

module Schemacop
  module V3
    class AllOfNode < CombinationNode
      def type
        :allOf
      end

      def _validate(data, result:)
        super_data = super
        return if super_data.nil?

        matches = matches(super_data)

        if matches.size != @items.size
          result.error <<~PLAIN.strip
            Matches #{matches.size} schemas but should match all of them:
            #{schema_messages(data).join("\n")}
          PLAIN
        end
      end

      def cast(value)
        items = matches(value)
        return value unless items

        casted_value = value.dup
        items.each { |i| casted_value = i.cast(casted_value) }
        return casted_value
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
schemacop-3.0.29 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.28 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.27 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.26 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.25 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.24 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.23 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.22 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.21 lib/schemacop/v3/all_of_node.rb
schemacop-3.0.20 lib/schemacop/v3/all_of_node.rb