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

Commit 46c3928

Browse files
committed
Require nine-digit ID numbers
Avoids issue #1.
1 parent 1c7216b commit 46c3928

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

app/models/student.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Student < ActiveRecord::Base
55

66
validates_presence_of :_student_first_name, :_student_last_name, :_student_id_number
77
validates_inclusion_of :_student_gender, :in => [ 'Male', 'Female' ]
8+
validates_length_of :_student_id_number, :is => 9
89
validates_uniqueness_of :_student_id_number
910
validates_numericality_of :_student_id_number
1011
validates_format_of :_student_email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i

config/locales/student.yml

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ en:
4848
models:
4949
student:
5050
attributes:
51+
_student_id_number:
52+
wrong_length: should be %{count} digits long
5153
_student_gender:
5254
inclusion: can't be blank
5355
_student_city:

0 commit comments

Comments
 (0)