class J2119::OnlyOneOfConstraint

Verify that there is only one of a selection of fields

Public Class Methods

new(fields) click to toggle source
Calls superclass method J2119::Constraint::new
# File lib/j2119/constraints.rb, line 42
def initialize(fields)
  super()
  @fields = fields
end

Public Instance Methods

check(node, path, problems) click to toggle source
# File lib/j2119/constraints.rb, line 47
def check(node, path, problems)
  if (@fields & node.keys).size > 1
    problems <<
      "#{path} may have only one of #{@fields}"
  end
end