Sha256: c510943f7b3b2b53490e30d7a23a9003be2ef8d18427061615db8c0bef341c7f

Contents?: true

Size: 277 Bytes

Versions: 2

Compression:

Stored size: 277 Bytes

Contents

# frozen_string_literal: true

require 'resolv'

module ValidatesHost
  class Ip
    def initialize(value)
      @value = value
    end

    def valid?
      return true if @value.blank?

      @value =~ Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_host-1.3.0 lib/validates_host/ip.rb
validates_host-1.2.0 lib/validates_host/ip.rb