Sha256: fa9adec565cd25d10354c700507259de78304398f8de7d800c7115e43fce75df
Contents?: true
Size: 514 Bytes
Versions: 2
Compression:
Stored size: 514 Bytes
Contents
require "ipaddr" class IpFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) error_message_block = lambda{ object.errors[attribute] << " must be a valid IPv4 or IPv6 address" } begin if value.is_a? IPAddr potential_ip = value.dup else potential_ip = IPAddr.new(value) end error_message_block.call unless potential_ip.ipv4? || potential_ip.ipv6? rescue ArgumentError error_message_block.call end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
metasploit_data_models-1.0.0.pre.rails.pre.4.0b | app/validators/ip_format_validator.rb |
metasploit_data_models-1.0.0.pre.rails.pre.4.0a | app/validators/ip_format_validator.rb |