Class: Opencdd::Validator::MandatoryRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/opencdd/validator/mandatory_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/mandatory_rule.rb', line 10

def applies?(context)
  context.requirement_mandatory?
end

#call(value, _context) ⇒ Object



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

def call(value, _context)
  return false if value.nil?
  return false if value.to_s.strip.empty?
  true
end

#idObject



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

def id
  "R07"
end

#message(_value, context) ⇒ Object



20
21
22
# File 'lib/opencdd/validator/mandatory_rule.rb', line 20

def message(_value, context)
  "R07: mandatory column #{context.column_iri} is empty"
end