Module: Label::SKOSXL::Validations

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
app/models/label/skosxl/validations.rb

Instance Method Summary collapse

Instance Method Details

#origin_has_to_be_escapedObject



17
18
19
20
21
# File 'app/models/label/skosxl/validations.rb', line 17

def origin_has_to_be_escaped
  unless Origin.new(origin).valid?
    errors.add :base, I18n.t('txt.models.label.origin_invalid')
  end
end

#referenced_published_concepts_has_to_be_validObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/label/skosxl/validations.rb', line 23

def referenced_published_concepts_has_to_be_valid
  published_label = self.published_version

  # check published concepts which use the current label as a pref label
  concepts.published.each do |concept|
    # pref labels without the current published one
    labels = concept.pref_labels.reject{ |l| l == published_label }

    unless labels.map(&:language).map(&:to_s).include?(Iqvoc::Concept.pref_labeling_languages.first.to_s)
      errors.add :base, I18n.t('txt.models.label.referenced_concepts_invalid')
    end
  end
end