OSU Validators
This gem contains rails ActiveRecord
validations for a user's emplid
, email
, and
name.#
.
Installation
Add this line to your application's Gemfile:
gem 'osu_validators'
And then execute:
$ bundle
Or install it yourself as:
$ gem install osu_validators
Usage
Assuming that a User
record has a emplid
, email
, and name_n
column:
class User < ActiveRecord::Base
validates_emplid_of :emplid
validates_osu_email_of :email
validates_name_n_of :name_n
end
class User < ActiveRecord::Base
validates :emplid, emplid: true
validates :email, osu_email: true
validates :name_n, name_n: true
end
There are also validations options for each validator: allow_nil
,
allow_blank
, and message
.
class User < ActiveRecord::Base
validates_emplid_of :emplid, allow_nil: true
validates :email, osu_email: { allow_blank: true }
validates :name_n, name_n: { message: "custom error message" }
end
Contributing
Bug reports and pull requests are welcome on code.osu.edu at https://code.osu.edu/asctech/osu_validators. 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.