Provides a UC Student Number (número de alumno de la Pontificia Universidad Católica de Chile) validation method for a string or a model's attribute.
Credits to Patricio López for his JS implementation.
Add this line to your application's Gemfile:
gem 'uc_number_validator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install uc_number_validator
If you want to validate a single string:
require 'uc_number_validator' # Unless working with Ruby on Rails
'1263476J'.valid_uc_number?
=> true
'1263476-J'.valid_uc_number?
=> false
If you want to validate a model attribute you just need to set uc_number: true
(like any model validation in Ruby on Rails):
class User < ActiveRecord::Base
attr_accessor :student_number
validates :student_number, uc_number: true
end
- Fork this repository
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'add my feature'
) - Push to your feature branch (
git push origin my-new-feature
) - Create a new Pull Request