class J2119::NonEmptyConstraint
Verify that array field is not empty
Public Class Methods
new(name)
click to toggle source
Calls superclass method
J2119::Constraint::new
# File lib/j2119/constraints.rb, line 58 def initialize(name) super() @name = name end
Public Instance Methods
check(node, path, problems)
click to toggle source
# File lib/j2119/constraints.rb, line 68 def check(node, path, problems) if node[@name] && node[@name].is_a?(Array) && (node[@name].size == 0) problems << "#{path}.#{@name} is empty, non-empty required" end end
to_s()
click to toggle source
# File lib/j2119/constraints.rb, line 63 def to_s conds = (@conditions.empty?) ? '' : " #{@conditions.size} conditions" "<Array field #{@name} should not be empty#{conds}>" end