Skip to content

Commit

Permalink
Allow use PIN to have more than 6 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
user890104 committed Mar 30, 2024
1 parent dcdcd01 commit ec28ace
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.bg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bg:
url: URL, започващ с „http://“ или „https://“
jabber: Jabber акаунт във формат „[email protected]
gpg_fingerprint: Отпечатък на GPG ключ с или без интервали
pin: използва се за отключване на вратата и трябва да е 6-цифрено число; оставете празно, ако не искате да го променяте
pin: използва се за отключване на вратата и трябва да е число с поне 6 цифри; оставете празно, ако не искате да го променяте
phone_numbers:
phone_number: телефонен номер с или без код за държава
network_device:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ en:
url: URL beginning with http:// or https://
jabber: Jabber account in the "[email protected]" 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:
Expand Down
4 changes: 2 additions & 2 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ec28ace

Please sign in to comment.