Class: SAFT::V2::XsdValidate
- Inherits:
-
Object
- Object
- SAFT::V2::XsdValidate
- Defined in:
- lib/saft/v2/xsd_validate.rb
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(content) ⇒ XsdValidate
constructor
A new instance of XsdValidate.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
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
#errors ⇒ Object
23 |
# File 'lib/saft/v2/xsd_validate.rb', line 23 def errors = @xml_errors |
#invalid? ⇒ Boolean
21 |
# File 'lib/saft/v2/xsd_validate.rb', line 21 def invalid? = !valid? |
#valid? ⇒ Boolean
20 |
# File 'lib/saft/v2/xsd_validate.rb', line 20 def valid? = @xml_errors.none? |