zellige.js
Version:
A Moroccan utility library for working with CIN, phone numbers, currency, addresses, dates, and more.
38 lines (37 loc) • 1.44 kB
TypeScript
export type OperatorType = 'IAM' | 'INWI' | 'ORANGE' | 'UNKNOWN';
export type PhoneType = 'MOBILE' | 'FIXED' | 'UNKNOWN';
export type PhoneFormat = 'NATIONAL' | 'INTERNATIONAL' | 'E164' | 'RFC3966';
export type PhoneInput = string | null | undefined;
export type ValidationError = keyof typeof ERRORS;
export interface PhoneValidationResult {
readonly isValid: boolean;
readonly error?: string;
readonly normalizedNumber?: string;
readonly type?: PhoneType;
readonly operator?: OperatorType;
readonly isFake?: boolean;
}
export interface PhoneDetails {
readonly type: PhoneType;
readonly operator: OperatorType;
readonly region: string;
readonly isValid: boolean;
readonly isFake: boolean;
readonly formats: Readonly<{
national: string;
international: string;
e164: string;
rfc3966: string;
}>;
}
export declare const ERRORS: {
readonly REQUIRED: "Phone number is required";
readonly INVALID_FORMAT: "Invalid phone number format";
readonly INVALID_PREFIX: "Invalid phone number prefix";
readonly INVALID_LENGTH: "Invalid phone number length";
readonly UNKNOWN_OPERATOR: "Unknown operator";
readonly UNKNOWN_TYPE: "Unknown phone type";
readonly EMPTY_INPUT: "Phone number cannot be empty";
readonly INVALID_COUNTRY: "Invalid country code";
readonly INVALID_CHARACTERS: "Phone number contains invalid characters";
};