otwarchive-symphonyarchive/app/validators/not_forbidden_name_validator.rb

10 lines
361 B
Ruby
Raw Permalink Normal View History

2026-03-11 22:22:11 +00:00
class NotForbiddenNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if value.nil?
return unless ArchiveConfig.FORBIDDEN_USERNAMES.include?(value.downcase)
# i18n-tasks-use t("activerecord.errors.messages.forbidden")
record.errors.add(attribute, :forbidden, **options.merge(value: value))
end
end