class LatitudeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value.present? && value >= -90 && value <= 90 record.errors[attribute] << (options[:message] || I18n.t('errors.messages.latitude')) end end end