Commit b6e9249a authored by peterhegman's avatar peterhegman

Rename regex constant to VALID_DOMAIN_REGEX

Per reviewer feedback
parent 142ec0a5
...@@ -14,14 +14,14 @@ class AllowedEmailDomain < ApplicationRecord ...@@ -14,14 +14,14 @@ class AllowedEmailDomain < ApplicationRecord
'icloud.com' 'icloud.com'
].freeze ].freeze
REGEX_VALIDATOR = /\w*\./.freeze VALID_DOMAIN_REGEX = /\w*\./.freeze
validates :group_id, presence: true validates :group_id, presence: true
validates :domain, presence: true validates :domain, presence: true
validate :allow_root_group_only validate :allow_root_group_only
validates :domain, exclusion: { in: RESERVED_DOMAINS, validates :domain, exclusion: { in: RESERVED_DOMAINS,
message: _('The domain you entered is not allowed.') } message: _('The domain you entered is not allowed.') }
validates :domain, format: { with: REGEX_VALIDATOR, validates :domain, format: { with: VALID_DOMAIN_REGEX,
message: _('The domain you entered is misformatted.') } message: _('The domain you entered is misformatted.') }
belongs_to :group, class_name: 'Group', foreign_key: :group_id belongs_to :group, class_name: 'Group', foreign_key: :group_id
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= _('Restrict membership by email domain') = _('Restrict membership by email domain')
.js-allowed-email-domains{ data: { hidden_input_id: hidden_input_id, .js-allowed-email-domains{ data: { hidden_input_id: hidden_input_id,
label_id: label_id, label_id: label_id,
regex_validator: AllowedEmailDomain::REGEX_VALIDATOR.source, regex_validator: AllowedEmailDomain::VALID_DOMAIN_REGEX.source,
disallowed_values: AllowedEmailDomain::RESERVED_DOMAINS.to_json, disallowed_values: AllowedEmailDomain::RESERVED_DOMAINS.to_json,
error_message: _('The domain you entered is misformatted.'), error_message: _('The domain you entered is misformatted.'),
disallowed_value_error_message: _('The domain you entered is not allowed.') } } disallowed_value_error_message: _('The domain you entered is not allowed.') } }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment