Class: Opencdd::Validator::SetRule
- Inherits:
-
Rule
- Object
- Rule
- Opencdd::Validator::SetRule
show all
- Defined in:
- lib/opencdd/validator/set_rule.rb
Constant Summary
Constants inherited
from Rule
Rule::REFERENCE_VALUE_KINDS
Instance Method Summary
collapse
Methods inherited from Rule
#blank?, #code_column?, #reference_kind?, #skip_blank?, #value_passes?
Instance Method Details
#applies?(context) ⇒ Boolean
10
11
12
|
# File 'lib/opencdd/validator/set_rule.rb', line 10
def applies?(context)
context.value_kind == :set_of_refs
end
|
#call(value, _context) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/opencdd/validator/set_rule.rb', line 14
def call(value, _context)
return true if value.nil? || value.to_s.strip.empty?
s = value.to_s.strip
return false unless s.start_with?("{") && s.end_with?("}")
body = s[1..-2]
balanced?(body)
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/opencdd/validator/set_rule.rb', line 6
def id
"R09"
end
|
#message(value, _context) ⇒ Object
22
23
24
|
# File 'lib/opencdd/validator/set_rule.rb', line 22
def message(value, _context)
"R09: set literal #{value.inspect} is not well-formed"
end
|