Sha256: b785db58c4a377283efe06c6cf4827c007e668af87fcc2d65c1505c97f3ace16

Contents?: true

Size: 634 Bytes

Versions: 36

Compression:

Stored size: 634 Bytes

Contents

module Schemacop
  module V3
    class IsNotNode < CombinationNode
      def type
        :not
      end

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

        if matches(super_data).any?
          result.error "Must not match schema: #{@items.first.as_json.as_json.inspect}."
        end
      end

      def as_json
        process_json([], type => @items.first.as_json)
      end

      def validate_self
        if @items.count != 1
          fail 'Node "is_not" only allows exactly one item.'
        end
      end

      def cast(data)
        data
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
schemacop-3.0.29 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.28 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.27 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.26 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.25 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.24 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.23 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.22 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.21 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.20 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.19 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.18 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.17 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.16 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.15 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.14 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.13 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.12 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.11 lib/schemacop/v3/is_not_node.rb
schemacop-3.0.10 lib/schemacop/v3/is_not_node.rb