Sha256: a5d489cc96d8773a1f7d97fa43343c1ef195bdd6d461d06ca6f0dcf1ebe5f8b7
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 Bytes
Contents
hydra-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 gem 'hydra-validations' ``` and ```sh bundle install ``` ### Example With a PORO, we have to include ActiveModel::Validations. ActiveRecord::Base and ActiveFedora::Base already include ActiveModel::Validations. ```ruby class Validatable include ActiveModel::Validations include Hydra::Validations attr_accessor :field validates :field, single_cardinality: true end > 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 ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hydra-validations-0.1.0 | README.md |