Sha256: cdf527715f70f18dcc6d593ab01dca7cfbc22b2e9d0c393d63f90a91f38ba79a

Contents?: true

Size: 332 Bytes

Versions: 7

Compression:

Stored size: 332 Bytes

Contents

# frozen_string_literal: true

class MacAddressValidator < BaseValidator

  REGEXP ||= [
    /^([\h]{2}[-|\.:|\s]){5}[\h]{2}?$/i,
    /^([\h]{4}[-|\.:|\s]){2}[\h]{4}?$/i,
    /^([\h]{6}[-|\.:|\s])[\h]{6}?$/i,
    /^[\h]{12}?$/i
  ].freeze

  private

  def valid_regexp?
    REGEXP.any? { |regexp| value.to_s =~ regexp }
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lite-validators-1.0.6 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.5 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.4 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.3 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.2 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.1 lib/lite/validators/mac_address_validator.rb
lite-validators-1.0.0 lib/lite/validators/mac_address_validator.rb