Class: J2119::DoesNotHaveFieldConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- J2119::DoesNotHaveFieldConstraint
- Defined in:
- lib/j2119/constraints.rb
Overview
Verify node does not have the named field
Instance Method Summary collapse
- #check(node, path, problems) ⇒ Object
-
#initialize(name) ⇒ DoesNotHaveFieldConstraint
constructor
A new instance of DoesNotHaveFieldConstraint.
- #to_s ⇒ Object
Methods inherited from Constraint
Constructor Details
#initialize(name) ⇒ DoesNotHaveFieldConstraint
Returns a new instance of DoesNotHaveFieldConstraint.
109 110 111 112 |
# File 'lib/j2119/constraints.rb', line 109 def initialize(name) super() @name = name end |
Instance Method Details
#check(node, path, problems) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/j2119/constraints.rb', line 119 def check(node, path, problems) if node[@name] problems << "#{path} has forbidden field \"#{@name}\"" end end |
#to_s ⇒ Object
114 115 116 117 |
# File 'lib/j2119/constraints.rb', line 114 def to_s conds = (@conditions.empty?) ? '' : " #{@conditions.size} conditions" "<Field #{@name} should be absent#{conds}>" end |