Sha256: c16de86c9577e0fed73f2eabce273088913b17ed4e062446784445039d8c78fe

Contents?: true

Size: 559 Bytes

Versions: 2

Compression:

Stored size: 559 Bytes

Contents

# frozen_string_literal: true

module MrCommon
  # Common regex patterns
  class Pattern
    class << self
      # Matches valid email addresses. Ensures that the @ symbol is
      # preceded by something resembling a username and followed by something
      # resembling a domain name.
      def email
        /\A\S+@\S+\.\S+\z/
      end

      # Matches most phone numbers a person could enter. Tests for at least 7 of
      # the characters that can appear in a phone number.
      def phone_number
        /[\d()\\x+\- ]{7,}/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mr_common-2.1.0 app/models/mr_common/pattern.rb
mr_common-2.0.0 app/models/mr_common/pattern.rb