Class: ValidatesXmlOf::Validator
- Inherits:
-
Object
- Object
- ValidatesXmlOf::Validator
- Defined in:
- lib/validates_xml_of/validator.rb
Instance Method Summary collapse
-
#initialize(xml, options = {}) ⇒ Validator
constructor
A new instance of Validator.
- #validate ⇒ Object
Constructor Details
#initialize(xml, options = {}) ⇒ Validator
Returns a new instance of Validator.
3 4 5 6 |
# File 'lib/validates_xml_of/validator.rb', line 3 def initialize(xml, = {}) self.xml = xml self. = end |
Instance Method Details
#validate ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/validates_xml_of/validator.rb', line 8 def validate = nil if xml.nil? || xml.empty? || !xml.is_a?(String) if [:schema] = [:schema_message] else = [:message] end end if !is_a_valid_xml?(xml) = [:message] end return unless .nil? if [:schema] schema = lookup_schema_file([:schema]) return [:schema_message] if schema.nil? if !schema.nil? && !is_a_valid_xml_based_on_schema?(xml, schema) = [:schema_message] end end return end |