Class: Schemacop::V3::IsNotNode
Instance Attribute Summary
Attributes inherited from Node
#as, #default, #description, #name, #options, #parent, #title
Instance Method Summary
collapse
#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
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_json ⇒ Object
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
|
#type ⇒ Object
4
5
6
|
# File 'lib/schemacop/v3/is_not_node.rb', line 4
def type
:not
end
|
#validate_self ⇒ Object
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
|