mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
Validate username site settings
This commit is contained in:
parent
afb178ba1f
commit
9611a1ac47
6 changed files with 57 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
class EmailSettingValidator
|
||||
def self.valid_value?(val)
|
||||
val == '' || EmailValidator.email_regex =~ val
|
||||
!val.present? || !!(EmailValidator.email_regex =~ val)
|
||||
end
|
||||
|
||||
def self.error_message(val)
|
||||
|
|
9
lib/validators/username_setting_validator.rb
Normal file
9
lib/validators/username_setting_validator.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class UsernameSettingValidator
|
||||
def self.valid_value?(val)
|
||||
!val.present? || User.where(username: val).exists?
|
||||
end
|
||||
|
||||
def self.error_message(val)
|
||||
I18n.t('site_settings.errors.invalid_username')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue