I am working on an issue where we have a large number of models with date fields. Looking for a way to have a validation that applies to all date fields across the project, and validates the date is before Dec 31, 9999.
The only solutions I have found involve going through and adding specific validations to each model, but my project lead would prefer a cleaner single-location solution and I can’t find anything that does this.
Just add a base class
class Base < ActiveRecord::Base
validates :date, presence: true
end
Then every model inherits the base class