Class: Glossarist::Validation::Rules::UuidFormatRule

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/validation/rules/uuid_format_rule.rb

Constant Summary collapse

UUID_RE =
/\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i.freeze

Instance Method Summary collapse

Methods inherited from Base

#applicable?, inherited

Instance Method Details

#categoryObject



10
# File 'lib/glossarist/validation/rules/uuid_format_rule.rb', line 10

def category = :integrity

#check(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/glossarist/validation/rules/uuid_format_rule.rb', line 14

def check(context)
  concept = context.concept
  fname = context.file_name
  issues = []

  uuid = concept.uuid
  if uuid && !uuid.to_s.empty? && !UUID_RE.match?(uuid.to_s)
    issues << issue(
      "concept UUID '#{uuid}' is not valid UUID format",
      location: fname,
      suggestion: "Use a valid UUID (e.g. 0ce27901-02ce-531e-8ba5-fdb136139d1a)",
    )
  end

  issues
end

#codeObject



9
# File 'lib/glossarist/validation/rules/uuid_format_rule.rb', line 9

def code = "GLS-016"

#scopeObject



12
# File 'lib/glossarist/validation/rules/uuid_format_rule.rb', line 12

def scope = :concept

#severityObject



11
# File 'lib/glossarist/validation/rules/uuid_format_rule.rb', line 11

def severity = "error"