No release in over 3 years
Low commit activity in last 3 years
Validates if an attribute has a valid xml content or a xsd valid content.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

>= 0
 Project Readme

ValidatesXmlOf

Build Status Code Climate Test Coverage

Validates if a given string contains a valid xml and validates based on defined schema too.

Installation

Add this line to your application's Gemfile:

gem 'validates_xml_of'

And then execute:

$ bundle

Or install it yourself as:

$ gem install validates_xml_of

Usage

Rails

If you do not want to use xsd:

class Post < ActiveRecord::Base
  ...

  validates :content, xml: true

  ...
end

And if you want to use xsd, you will need to define an initializer to setup a path for your schemas:

ValidatesXmlOf.setup do |config|
  config.schema_paths = "lib/xsds"
end

After, you need to set your validation to specify what schema you are looking for:

class Post < ActiveRecord::Base
  ...
  # The schema must be in lib/xsds/Schema.xsd
  validates :content, xml: { schema: 'Schema' }
  ...
end

PS: Coming soon, I will implement a generator to create this initializer

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/brunoarueira/validates_xml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.