]> cat aescling's git repositories - mastodon.git/blob - app/validators/unreserved_validator.rb
Added support for configurable reserved usernames (fix of #1382) (#3566)
[mastodon.git] / app / validators / unreserved_validator.rb
1 # frozen_string_literal: true
2
3 class UnreservedValidator < ActiveModel::EachValidator
4 def validate_each(record, attribute, value)
5 return if value.nil?
6 record.errors.add(attribute, I18n.t('accounts.reserved_username')) if reserved_username?(value)
7 end
8
9 private
10
11 def reserved_username?(value)
12 return false unless Setting.reserved_usernames
13 Setting.reserved_usernames.include?(value.downcase)
14 end
15 end
This page took 0.113319 seconds and 6 git commands to generate.