Class: Dcc::Validate::Issue
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Dcc::Validate::Issue
- Defined in:
- lib/dcc/validate/issue.rb
Overview
A single validation issue (XSD error, Schematron failed assert, or business-rule violation). Carries enough metadata for both human and machine reporting.
Class Method Summary collapse
-
.build(severity:, message:, code: nil, line: nil, column: nil, path: nil, source: nil) ⇒ Object
Convenience constructor used by validators.
Instance Method Summary collapse
-
#failing? ⇒ Boolean
Whether this issue fails validation (severity == error).
- #to_s ⇒ Object
Class Method Details
.build(severity:, message:, code: nil, line: nil, column: nil, path: nil, source: nil) ⇒ Object
Convenience constructor used by validators.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dcc/validate/issue.rb', line 27 def self.build(severity:, message:, code: nil, line: nil, column: nil, path: nil, source: nil) new( severity: ::Dcc::Validate::Severity.normalize(severity), message: , code: code, line: line, column: column, path: path, source: source, ) end |
Instance Method Details
#failing? ⇒ Boolean
Returns whether this issue fails validation (severity == error).
40 41 42 |
# File 'lib/dcc/validate/issue.rb', line 40 def failing? severity == ::Dcc::Validate::Severity::ERROR end |
#to_s ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dcc/validate/issue.rb', line 44 def to_s loc = [] loc << "line #{line}" if line loc << "col #{column}" if column loc << path if path loc_str = loc.empty? ? "" : " [#{loc.join(' ')}]" code_str = code ? "(#{code}) " : "" src_str = source ? "#{source}: " : "" "#{src_str}#{severity.upcase} #{code_str}#{}#{loc_str}" end |