module ActiveModel::Validations::ClassMethods
def validators_on(*attributes)
# #
# => [
Person.validators_on(:name)
end
validates_inclusion_of :age, in: 0..99
validates_presence_of :name
attr_accessor :name, :age
include ActiveModel::Validations
class Person
List all validators that are being used to validate a specific attribute.
def validators_on(*attributes) attributes.flat_map do |attribute| _validators[attribute.to_sym] end end