class CqmValidators::Schema::Validator
Public Class Methods
new(name, schema_file)
click to toggle source
# File lib/schema_validator.rb, line 8 def initialize(name, schema_file) @name = name @schema_file = schema_file @xsd = Nokogiri::XML::Schema(File.new(@schema_file)) end
Public Instance Methods
validate(document, data = {})
click to toggle source
Validate the document against the configured schema
# File lib/schema_validator.rb, line 15 def validate(document, data = {}) @xsd.errors.clear doc = get_document(document) @xsd.validate(doc).map do |error| build_error(error.message, '/', data[:file_name]) end end