replaces length 9 validation by format validation: only numbers, spaces and plus sign allowed

This commit is contained in:
kikito
2016-04-13 19:27:04 +02:00
parent 005bd26965
commit 92ecd7c983
2 changed files with 10 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ class Verification::Sms
attr_accessor :user, :phone, :confirmation_code
validates_presence_of :phone
validates :phone, length: { is: 9 }
validates :phone, format: { with: /\A[\d \+]+\z/ }
validate :uniqness_phone
def uniqness_phone