openSUSE/open-build-service

View on GitHub
src/api/app/validators/allowed_user_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class AllowedUserValidator < ActiveModel::Validator
  def validate(record)
    # NOTE: it could be more generic and check 'locked' users or other possible banned ones
    record.errors.add(:base, "Couldn't find user #{record.user.login}") if record.user && record.user.is_nobody?
  end
end