discourse/lib/validators/allowed_ip_address_validato...

9 lines
297 B
Ruby
Raw Normal View History

class AllowedIpAddressValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if record.ip_address and ScreenedIpAddress.should_block?(record.ip_address)
record.errors.add(attribute, options[:message] || I18n.t('user.ip_address.blocked'))
end
end
end