README.md in hydra-validations-0.0.1 vs README.md in hydra-validations-0.1.0
- old
+ new
@@ -1,10 +1,16 @@
hydra-validations
=======================
-Custom validations for Hydra applications based on ActiveModel::Validations.
+Custom validators for Hydra applications based on ActiveModel::Validations.
+### Dependencies
+
+* Ruby >= 1.9.3
+* ActiveModel 4.x
+* ActiveFedora 7.x
+
### Installation
Include in your Gemfile:
```ruby
@@ -15,18 +21,35 @@
```sh
bundle install
```
-### Usage
+### Example
-To include helper methods:
+With a PORO, we have to include ActiveModel::Validations.
+ActiveRecord::Base and ActiveFedora::Base already include ActiveModel::Validations.
```ruby
-include Hydra::Validations
-```
+class Validatable
+ include ActiveModel::Validations
+ include Hydra::Validations
+ attr_accessor :field
+ validates :field, single_cardinality: true
+end
-For example:
-
-```ruby
-validates_single_cardinality_of :my_single_valued_attr
+> Validatable.validators
+ => [#<Hydra::Validations::SingleCardinalityValidator:0x007fb91d1e9460 @attributes=[:field], @options={}>]
+> v = Validatable.new
+ => #<Validatable:0x007fb91d1c9188>
+> v.field = "foo"
+ => "foo"
+> v.valid?
+ => true
+> v.field = ["foo"]
+ => ["foo"]
+> v.valid?
+ => true
+> v.field = ["foo", "bar"]
+ => ["foo", "bar"]
+> v.valid?
+ => false
```