Class: SAFT::V2::XsdValidate

Inherits:
Object
  • Object
show all
Defined in:
lib/saft/v2/xsd_validate.rb

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ XsdValidate

Returns a new instance of XsdValidate.



10
11
12
13
14
15
16
17
18
# File 'lib/saft/v2/xsd_validate.rb', line 10

def initialize(content)
  @xml_errors = []
  doc = Nokogiri::XML(content)
  @xml_errors.push(*doc.errors)
  xsd = Nokogiri::XML::Schema(XSD_PATH)
  @xml_errors.push(*xsd.validate(doc))
  # All error are of type Nokogiri::XML::SyntaxError
  # https://nokogiri.org/rdoc/Nokogiri/XML/SyntaxError.html
end

Instance Method Details

#errorsObject



23
# File 'lib/saft/v2/xsd_validate.rb', line 23

def errors = @xml_errors

#invalid?Boolean

Returns:

  • (Boolean)


21
# File 'lib/saft/v2/xsd_validate.rb', line 21

def invalid? = !valid?

#valid?Boolean

Returns:

  • (Boolean)


20
# File 'lib/saft/v2/xsd_validate.rb', line 20

def valid? = @xml_errors.none?