Sha256: e0b9513e3be32aafd82c1fc81437754d6ae1b123fc47920aaa78e147e0c207ab
Contents?: true
Size: 312 Bytes
Versions: 5
Compression:
Stored size: 312 Bytes
Contents
class IpValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ record.errors[attribute] << (options[:message] || I18n.t('errors.messages.ip')) end end end
Version data entries
5 entries across 5 versions & 1 rubygems