mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Validate username site settings
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user