0.0
No commit activity in last 3 years
No release in over 3 years
Validations for Ohm models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 5.8
~> 11.0
~> 0.39

Runtime

>= 2.0, ~> 3.0
~> 1.0
 Project Readme

ohm-validations Build Status

Validations for Ohm::Model.

Installation

Add this line to your application's Gemfile:

gem "ohm-validations"

And then execute:

$ bundle

Or install it yourself as:

$ gem install ohm-validations

Usage

class User < Ohm::Model
  include Ohm::Validations

  attribute :name
  attribute :email

  attr_reader :before, :after

  protected

  def validate
    assert_present(:name)
    assert_email(:email)
  end

  def before_validate
    @before = true
  end

  def after_validate
    @after = true
  end
end

User.create
# => nil

user = User.new
user.valid? # => false

user.update_attributes(name: "jhon", email: "jhon@doe.com")
user.valid? # => true
user.save   # => user

user.before # => true
user.after  # => true

Check scrivener project for more information about the available validations.

Contributing

Fork the project with:

$ git clone git@github.com:frodsan/ohm-validations.git

To install dependencies, use:

$ bundle install

To run the test suite, do:

$ rake test

For bug reports and pull requests use GitHub.

License

This gem is released under the MIT License.