Module: Dcc::Validate::Severity
- Defined in:
- lib/dcc/validate/severity.rb
Overview
Severity levels for validation issues. Matches PTB's Schematron roles plus the standard error/warning/info distinction.
Constant Summary collapse
- ERROR =
:error- WARNING =
:warning- INFO =
:info- UNKNOWN =
:unknown- ALL =
[ERROR, WARNING, INFO, UNKNOWN].freeze
Class Method Summary collapse
-
.failing?(severity) ⇒ Boolean
Whether issues at this severity fail validation.
-
.normalize(value) ⇒ Symbol
Coerce a string/symbol to a canonical severity symbol.
Class Method Details
.failing?(severity) ⇒ Boolean
Returns whether issues at this severity fail validation.
33 34 35 |
# File 'lib/dcc/validate/severity.rb', line 33 def failing?(severity) severity == ERROR end |
.normalize(value) ⇒ Symbol
Coerce a string/symbol to a canonical severity symbol.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dcc/validate/severity.rb', line 18 def normalize(value) return value if ALL.include?(value) return UNKNOWN unless value sym = value.to_s.downcase.sub(/\A(strict_)?/, "").to_sym case sym when :err then ERROR when :warn then WARNING when :information, :informational then INFO else ALL.include?(sym) ? sym : UNKNOWN end end |