Add details
to error response for POST /api/v1/accounts
in REST API (#15803)
This commit is contained in:
parent
b4cb8c3c83
commit
9aa37b32c3
12 changed files with 72 additions and 23 deletions
|
@ -3,9 +3,10 @@
|
|||
class UnreservedUsernameValidator < ActiveModel::Validator
|
||||
def validate(account)
|
||||
@username = account.username
|
||||
return if @username.nil?
|
||||
|
||||
account.errors.add(:username, I18n.t('accounts.reserved_username')) if reserved_username?
|
||||
return if @username.blank?
|
||||
|
||||
account.errors.add(:username, :reserved) if reserved_username?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue