Sha256: 89793ba51d1382a64212fd32773b2dfbbb05941466b42bd6d3dca6818d2c1e63

Contents?: true

Size: 310 Bytes

Versions: 6

Compression:

Stored size: 310 Bytes

Contents

class IpValidator < ActiveModel::EachValidator
  def validate_each(object, 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]?)$/ 
      object.errors[attribute] << (options[:message] || "is not formatted properly")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
drexed-validators-0.0.13 app/validators/ip_validator.rb
drexed-validators-0.0.12 app/validators/ip_validator.rb
drexed-validators-0.0.11 app/validators/ip_validator.rb
drexed-validators-0.0.10 app/validators/ip_validator.rb
drexed-validators-0.0.9 app/validators/ip_validator.rb
drexed-validators-0.0.7 app/validators/ip_validator.rb