Class: Opencdd::Validator::DataTypeRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/opencdd/validator/data_type_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

Returns:

  • (Boolean)


10
11
12
# File 'lib/opencdd/validator/data_type_rule.rb', line 10

def applies?(context)
  context.column_iri == Opencdd::PropertyIds::MDC_P022
end

#call(value, _context) ⇒ Object



14
15
16
17
18
19
# File 'lib/opencdd/validator/data_type_rule.rb', line 14

def call(value, _context)
  return true if value.nil? || value.to_s.strip.empty?
  !Opencdd::DataType.parse(value.to_s).nil?
rescue ArgumentError
  false
end

#idObject



6
7
8
# File 'lib/opencdd/validator/data_type_rule.rb', line 6

def id
  "R12"
end

#message(value, _context) ⇒ Object



21
22
23
# File 'lib/opencdd/validator/data_type_rule.rb', line 21

def message(value, _context)
  "R12: data type expression #{value.inspect} is not well-formed"
end