Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
Require nine-digit ID numbers
Browse files Browse the repository at this point in the history
Avoids issue #1.
  • Loading branch information
maxg committed Dec 14, 2011
1 parent 1c7216b commit 46c3928
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Student < ActiveRecord::Base

validates_presence_of :_student_first_name, :_student_last_name, :_student_id_number
validates_inclusion_of :_student_gender, :in => [ 'Male', 'Female' ]
validates_length_of :_student_id_number, :is => 9
validates_uniqueness_of :_student_id_number
validates_numericality_of :_student_id_number
validates_format_of :_student_email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
Expand Down
2 changes: 2 additions & 0 deletions config/locales/student.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ en:
models:
student:
attributes:
_student_id_number:
wrong_length: should be %{count} digits long
_student_gender:
inclusion: can't be blank
_student_city:
Expand Down

0 comments on commit 46c3928

Please sign in to comment.