Class: NotUsernameValidator
- Inherits:
-
Object
- Object
- NotUsernameValidator
- Defined in:
- lib/validators/not_username_validator.rb
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ NotUsernameValidator
constructor
A new instance of NotUsernameValidator.
- #valid_value?(val) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ NotUsernameValidator
Returns a new instance of NotUsernameValidator.
4 5 6 |
# File 'lib/validators/not_username_validator.rb', line 4 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#error_message ⇒ Object
12 13 14 |
# File 'lib/validators/not_username_validator.rb', line 12 def I18n.t("site_settings.errors.valid_username") end |
#valid_value?(val) ⇒ Boolean
8 9 10 |
# File 'lib/validators/not_username_validator.rb', line 8 def valid_value?(val) val.blank? || !User.where(username: val).exists? end |