Class: ActiveModel::Validations::XmlValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::XmlValidator
- Defined in:
- lib/validates_xml_of/active_model.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/validates_xml_of/active_model.rb', line 7 def validate_each(record, attribute, value) xml_content = value if defined?(::CarrierWave) && value.is_a?(::CarrierWave::Uploader::Base) xml_content = record.send(attribute).read end validator = ValidatesXmlOf::Validator.new(xml_content, ) error = validator.validate return if error.blank? record.errors.add(attribute, error) end |