Add more explicit message for format validation errors

This commit is contained in:
Andreas Nedbal 2023-01-21 13:14:15 +01:00 committed by Andreas Nedbal
parent 47bccdb0c3
commit fc30bf8cac
2 changed files with 5 additions and 1 deletions

View File

@ -63,7 +63,7 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
validates :email, fake_email: true, typoed_email: true
validates :screen_name,
presence: true,
format: { with: SCREEN_NAME_REGEX },
format: { with: SCREEN_NAME_REGEX, message: I18n.t("activerecord.validation.user.screen_name.format") },
length: { minimum: 1, maximum: 16 },
uniqueness: { case_sensitive: false },
screen_name: true

View File

@ -96,6 +96,10 @@ en:
primary_color: "The primary/brand colour of the site, used for navigation, links, etc."
success_color: "Colour used for messages if something went through successfully."
warning_color: "Colour used for warnings if something non-critical has happened."
validation:
user:
screen_name:
format: "contains invalid characters"
helpers:
submit:
user: