phone

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: GPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Overview

Package phone provides Mauritanian phone number validation and formatting.

This package validates phone numbers according to Mauritanian numbering standards, supporting the three main mobile operators with prefixes 2, 3, and 4.

Usage

import "github.com/CatoSystems/rim-pay/pkg/phone"

// Create and validate phone number
phone, err := phone.NewPhone("+22233445566")
if err != nil {
	// Handle invalid phone number
}

fmt.Println(phone.String())           // +22233445566
fmt.Println(phone.Number())           // 33445566
fmt.Println(phone.IsValid())          // true

Supported Formats

The following phone number formats are accepted:

  • +22233445566 (international format)
  • 22233445566 (national format)
  • 33445566 (local format - prefix 2, 3, or 4 assumed)

Valid Prefixes

Mauritanian mobile numbers use the following prefixes:

  • 2: Mauritel (legacy)
  • 3: Chinguitel
  • 4: Mattel

Validation Rules

Phone numbers must:

  • Start with country code +222 (optional in input)
  • Have a valid prefix (2, 3, or 4)
  • Be exactly 8 digits after the country code
  • Contain only numeric characters

Invalid examples:

  • +22255667788 (prefix 5 not supported)
  • +222334455 (too short)
  • +2223344556677 (too long)
  • +22233445abc (contains letters)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidMauritanianNumber

func IsValidMauritanianNumber(number string) bool

Types

type Phone

type Phone struct {
	// contains filtered or unexported fields
}

func NewPhone

func NewPhone(number string) (*Phone, error)

func (*Phone) ForProvider

func (mp *Phone) ForProvider(includeCountryCode bool) string

func (*Phone) InternationalFormat

func (mp *Phone) InternationalFormat() string

func (*Phone) LocalFormat

func (mp *Phone) LocalFormat() string

func (*Phone) Number

func (mp *Phone) Number() string

func (*Phone) String

func (mp *Phone) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL