Fixes #7616 - Use validates_lengths_from_database

> Note that unfortunately validates_lengths_from_database cannot be applied at a global level directly against ActiveRecord::Base, since the validates_length_from_database method requires the class to have a table name (with the ability to load the schema).