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