My understanding is that I can customize error messages in the localization files. I'm currently trying to customize the error message for an invalid username field on my User model:
User.rb
class User < ActiveRecord::Base
validates :username, length: { within: 3..25 },
format: /\A(?=.*[a-z])[a-z\d]+\Z/i,
uniqueness: true
en.yml (localization file)
en:
activerecord:
errors:
models:
user:
attributes:
username:
format: "CUSTOM MESSAGE!"
The error message I receive, however, is the default "is invalid" message (or "Username is invalid" if I get the full_messages version).