Sha256: ecb5a2827f6ea77bf4744286ad0e9fe266930ee225bf9e4b5c6443f11fe73723

Contents?: true

Size: 330 Bytes

Versions: 2

Compression:

Stored size: 330 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('active_validation.errors.messages.ip'))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_validation-1.1.0 lib/active_validation/validators/ip_validator.rb
active_validation-1.0.0 lib/active_validation/validators/ip_validator.rb