A standalone NRIC validator as well as ActiveModel validator for use in your Rails models.
Add this line to your application's Gemfile:
gem 'validator-nric'
As a standalone validator:
Validator::Nric.check('SXXXXXXXC') # => true or false
Use with ActiveModel model:
class User < ActiveRecord::Base
validates :identity_card, nric: true, presence: true, uniqueness: true
end
- Fork it ( https://github.com/mech/validator-nric/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request