lib/respect/format_validator.rb
def validate_ipv4_addr(value)
      ipaddr = IPAddr.new(value)
      unless ipaddr.ipv4?
        raise ValidationError, "IP address '#{value}' is not IPv4"
      end
      ipaddr
    rescue ArgumentError => e
      raise ValidationError, "invalid IPv4 address '#{value}' - #{e.message}"
    end
def validate_ipv4_addr(value)
      ipaddr = IPAddr.new(value)
      unless ipaddr.ipv4?
        raise ValidationError, "IP address '#{value}' is not IPv4"
      end
      ipaddr
    rescue ArgumentError => e
      raise ValidationError, "invalid IPv4 address '#{value}' - #{e.message}"
    end
def validate_ipv4_addr ( value ) ipaddr = IPAddr . new ( value ) unless ipaddr . ipv4? raise ValidationError , "IP address '#{value}' is not IPv4" end ipaddr rescue ArgumentError => e raise ValidationError , "invalid IPv4 address '#{value}' - #{e.message}" end
Validate IPV4 using the standard "ipaddr" ruby module.
Validate IPV4 using the standard ipaddr ruby module .