diff --git a/app/models/user.rb b/app/models/user.rb index 5057e5e..a7f9ffb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,7 +20,7 @@ class User < ApplicationRecord validates :github, format: {with: /\A[a-z0-9][a-z0-9-]{,38}\z/i}, allow_blank: true validates :jabber, format: {with: /\A[^@]+@[^@]+\z/}, allow_blank: true validates :gpg_fingerprint, format: {with: /\A[0-9a-f]{4}( ?)([0-9a-f]{4}\1){4}\1{0,2}([0-9a-f]{4}\1){4}[0-9a-f]{4}\z/i}, allow_blank: true - validates :pin, numericality: true, length: {is: 6}, allow_blank: true, confirmation: true + validates :pin, numericality: true, length: {minimum: 6}, allow_blank: true, confirmation: true validates :locale, presence: true, inclusion: {in: I18n.available_locales.map(&:to_s)} accepts_nested_attributes_for :phone_numbers, update_only: true, allow_destroy: true, reject_if: :all_blank diff --git a/config/locales/simple_form.bg.yml b/config/locales/simple_form.bg.yml index 7c2b2c6..d4754b1 100644 --- a/config/locales/simple_form.bg.yml +++ b/config/locales/simple_form.bg.yml @@ -17,7 +17,7 @@ bg: url: URL, започващ с „http://“ или „https://“ jabber: Jabber акаунт във формат „username@domain.com“ gpg_fingerprint: Отпечатък на GPG ключ с или без интервали - pin: използва се за отключване на вратата и трябва да е 6-цифрено число; оставете празно, ако не искате да го променяте + pin: използва се за отключване на вратата и трябва да е число с поне 6 цифри; оставете празно, ако не искате да го променяте phone_numbers: phone_number: телефонен номер с или без код за държава network_device: diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 7137c3f..acfbf84 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -14,7 +14,7 @@ en: url: URL beginning with http:// or https:// jabber: Jabber account in the "username@domain.com" format gpg_fingerprint: GPG fingerprint with or without spaces - pin: it is used to lock/unlock the doors and must be a 6-digit number; leave empty if you do not want to change it + pin: it is used to lock/unlock the doors and must be a number with at least 6 digits; leave empty if you do not want to change it phone_numbers: phone_number: phone number with optional country code network_device: diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 67f0789..70ee1d0 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -238,10 +238,10 @@ expect(build(:user, pin: nil)).to_not have_error_on :pin end - it "must be a 6-digit number when it's not nil" do + it "must be a number with 6 or more digits when it's not nil" do expect(build(:user, pin: 123456)).to_not have_error_on :pin + expect(build(:user, pin: 1234567890)).to_not have_error_on :pin expect(build(:user, pin: 123)).to have_error_on :pin - expect(build(:user, pin: 1234567)).to have_error_on :pin expect(build(:user, pin: "abcdef")).to have_error_on :pin end