Class: Lutaml::Xsd::Commands::ValidateCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Lutaml::Xsd::Commands::ValidateCommand
- Defined in:
- lib/lutaml/xsd/commands/validate_command.rb
Overview
CLI command for XML instance validation
Validates XML files against XSD schemas with support for:
-
Single file validation
-
Multiple file validation (glob patterns)
-
Various output formats (text, json, yaml)
-
Exit codes based on validation result
Instance Attribute Summary collapse
-
#schema_source ⇒ Object
readonly
Returns the value of attribute schema_source.
-
#xml_files ⇒ Object
readonly
Returns the value of attribute xml_files.
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize(xml_files, schema_source, options = {}) ⇒ ValidateCommand
constructor
Initialize validate command.
-
#run ⇒ void
Run validation command.
Constructor Details
#initialize(xml_files, schema_source, options = {}) ⇒ ValidateCommand
Initialize validate command
24 25 26 27 28 |
# File 'lib/lutaml/xsd/commands/validate_command.rb', line 24 def initialize(xml_files, schema_source, = {}) super() @xml_files = Array(xml_files) @schema_source = schema_source end |
Instance Attribute Details
#schema_source ⇒ Object (readonly)
Returns the value of attribute schema_source.
17 18 19 |
# File 'lib/lutaml/xsd/commands/validate_command.rb', line 17 def schema_source @schema_source end |
#xml_files ⇒ Object (readonly)
Returns the value of attribute xml_files.
17 18 19 |
# File 'lib/lutaml/xsd/commands/validate_command.rb', line 17 def xml_files @xml_files end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Run validation command
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lutaml/xsd/commands/validate_command.rb', line 33 def run validate_inputs files = if files.empty? error "No XML files found matching the specified patterns" exit 1 end validator = create_validator results = validate_files(files, validator) output_results(results) exit_with_status(results) rescue StandardError => e error "Validation failed: #{e.}" verbose_output e.backtrace.join("\n") if verbose? exit 1 end |