Class: Opencdd::Validator::SynonymRule
- Inherits:
-
Rule
- Object
- Rule
- Opencdd::Validator::SynonymRule
show all
- Defined in:
- lib/opencdd/validator/synonym_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
13
|
# File 'lib/opencdd/validator/synonym_rule.rb', line 10
def applies?(context)
context.column_iri == Opencdd::PropertyIds::MDC_P004_2 ||
context.column_iri == Opencdd::PropertyIds::MDC_P007
end
|
#call(value, _context) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/opencdd/validator/synonym_rule.rb', line 15
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].strip
return true if body.empty?
tuples = body.split(/\)\s*,\s*/).map(&:strip)
tuples.all? { |t| t.start_with?("(") }
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/opencdd/validator/synonym_rule.rb', line 6
def id
"R10"
end
|
#message(value, _context) ⇒ Object
25
26
27
|
# File 'lib/opencdd/validator/synonym_rule.rb', line 25
def message(value, _context)
"R10: synonymous-name literal #{value.inspect} is not well-formed"
end
|