This is a set of extensions for PORO objects to help in data coercion and validation. It was extracted from rom-rails and for now it uses Virtus and ActiveModel.
The package includes:
ROM::Attributesfor defining input attributes with types and coercion rules
ROM::Validatora standalone validator object extension built on top of
ActiveModel::Validationswith additional features like nested validators
This gem is built on top of existing 3rd party gems that have proven to be stable and good-enough. Unfortunately neither Virtus nor ActiveModel do not meet certain design requirements to be a good fit in the long term.
For that reason we're exploring how to build a better foundation for rom-model. Specifically following initiatives are taking place:
- Exploring a lower-level validation library with great composability features and simple interface
- Investigating a lower-level input data sanitization/coercion library that would be a perfect fit for handling web forms and json input
This project will provide convenient interfaces on top of robust lower-level tools and if it turns out to be too big we'll split it into smaller gems.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install rom-model