Class: Schemacop::V3::IsNotNode

Inherits:
CombinationNode show all
Defined in:
lib/schemacop/v3/is_not_node.rb

Instance Attribute Summary

Attributes inherited from Node

#as, #default, #description, #name, #options, #parent, #title

Instance Method Summary collapse

Methods inherited from CombinationNode

#add_child, dsl_methods, #init

Methods inherited from Node

allowed_options, #allowed_types, #children, create, #create, dsl_methods, #dsl_node, #dsl_scm, #init, #initialize, #required?, resolve_class, #schemas, supports_children, supports_children_options, #used_external_schemas, #validate

Constructor Details

This class inherits a constructor from Schemacop::V3::Node

Instance Method Details

#_validate(data, result:) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/schemacop/v3/is_not_node.rb', line 8

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

#as_jsonObject



17
18
19
# File 'lib/schemacop/v3/is_not_node.rb', line 17

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

#cast(data) ⇒ Object



27
28
29
# File 'lib/schemacop/v3/is_not_node.rb', line 27

def cast(data)
  data
end

#typeObject



4
5
6
# File 'lib/schemacop/v3/is_not_node.rb', line 4

def type
  :not
end

#validate_selfObject



21
22
23
24
25
# File 'lib/schemacop/v3/is_not_node.rb', line 21

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