Update to use constant instead of magic numbers

This commit is contained in:
Mir Bhatia
2026-04-30 15:07:47 +02:00
parent c91300529d
commit 997166bb61
3 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -35,6 +35,8 @@ class Setting < ApplicationRecord
extend Aliases
extend MailSettings
PASSWORD_MAX_LENGTH = 128
ENCODINGS = %w(US-ASCII
windows-1250
windows-1251
@@ -95,7 +97,7 @@ class Setting < ApplicationRecord
numericality: {
only_integer: true,
greater_than_or_equal_to: 1,
less_than_or_equal_to: 128,
less_than_or_equal_to: PASSWORD_MAX_LENGTH,
if: ->(setting) { setting.name == "password_min_length" }
}
@@ -53,7 +53,7 @@ See COPYRIGHT and LICENSE files for more details.
type: :number,
size: 6,
min: 1,
max: 128,
max: Setting::PASSWORD_MAX_LENGTH,
input_width: :small
form.check_box_group(name: :password_active_rules,
+1 -1
View File
@@ -829,7 +829,7 @@ module Settings
password_min_length: {
default: 10,
format: :integer,
allowed: (1..128)
allowed: -> { 1..Setting::PASSWORD_MAX_LENGTH }
},
# TODO: turn into array of ints
# Requires a migration to be written