A TypeScript-based phone ๐ข Numsy with CSV/Excel parsing capabilities built with NestJS. This application validates and sanitizes Indian phone numbers, providing a clean way to process bulk contact data.
/, -, or spacesThe application focuses on extracting phone numbers and recognizes 120+ field name variations, including:
Common Names:
phone, mobile, contact, telephone, cell, telphone_number, mobile_number, contact_numberphonenumber, mobilenumber, contactnumberCarrier/Type Specific:
whatsapp, whatsapp_number, whatsapp_mobilecustomer_phone, client_mobile, business_phoneoffice_phone, work_mobile, home_phone, personal_mobileContext Specific:
primary_phone, secondary_mobile, alternate_phoneemergency_contact, registered_mobile, verified_phoneuser_phone, login_mobile, otp_phoneAbbreviated:
phone_no, mobile_no, contact_no, tel_noAnd many more variations with different separators (spaces, underscores, dots, etc.)
The system uses regex-based pattern matching to intelligently detect phone columns regardless of naming convention.
All other fields in your CSV/Excel file are optional and will be preserved in the output:
Install pnpm (if not already installed):
npm install -g pnpm
# or use Node.js Corepack
corepack enable
cd number-processor
pnpm install
pnpm run build
Start the development server with hot-reload:
pnpm run start:dev
The application will be available at http://localhost:3000
Build and run in production:
pnpm run build
pnpm run start:prod
GET /api/health
Returns server health status.
POST /api/upload
Request:
multipart/form-datafile.csv, .xlsx, .xlsResponse:
{
"success": true,
"message": "File processed successfully",
"downloadId": "processed_1234567890",
"summary": {
"totalRecords": 100,
"validRecords": 85,
"invalidRecords": 15,
"phoneColumnDetected": "phone",
"analytics": {
"totalNumbersExtracted": 120,
"totalValidNumbers": 85,
"totalInvalidNumbers": 35,
"recordsWithMultipleNumbers": 18,
"averageNumbersPerRecord": 1.2,
"duplicateNumbers": 5,
"uniqueValidNumbers": 80
}
}
}
GET /api/download/:id
Downloads a ZIP file containing:
The analytics text file includes:
Summary Statistics:
Carrier Series Distribution:
Top Number Prefixes:
Duplicate Detection:
Field Distribution:
Validation Details:
The application can now extract and process multiple phone numbers from a single cell:
Supported Separators:
/-Example Input:
Customer Name,Mobile Number,City
John Doe,9876543210 / 8765432109,Mumbai
Jane Smith,7654321098-9876543211,Delhi
Bob Wilson,8765432109 9876543212,Bangalore
Output Behavior:
Analytics Provided:
Valid Numbers:
+91, 0091, 9109876543210)Automatic Sanitization:
+, -, ` ` (spaces), ., (, )+91, 0091, 91Single Numbers:
9876543210 - Standard format98765-43210 - With hyphens98765 43210 - With spaces+91 9876543210 - With country code and plus+919876543210 - Compact format with plus0091 9876543210 - International format919876543210 - With country code (no plus)9876 543 210 - Multiple spaces9876.543.210 - With dots(98765) 43210 - With parentheses09876543210 - With leading zeroMultiple Numbers (Separated):
+91 98765432109198765432109876 543 2109876543210 / 8765432109 (multiple numbers)7654321098-9876543211 (multiple numbers)8765432109 9876543212 (multiple numbers with spaces)+91) is automatically stripped987654321098765-4321098765 43210+91 98765432109198765432109876 543 2109999999999)number-processor/
โโโ src/
โ โโโ controllers/
โ โ โโโ app.controller.ts # Main API controller
โ โโโ services/
โ โ โโโ phone-validator.service.ts # Phone validation logic
โ โ โโโ file-parser.service.ts # CSV/Excel parsing
โ โ โโโ file-processor.service.ts # File processing orchestration
โ โโโ app.module.ts # Root module
โ โโโ main.ts # Application entry point
โโโ public/
โ โโโ index.html # Web UI
โโโ uploads/ # Temporary upload directory
โโโ temp/ # Temporary processing directory
โโโ package.json
โโโ tsconfig.json
โโโ nest-cli.json
โโโ README.md
validateAndSanitize())PhoneValidatorService)PhoneValidationResult)MAX_FILE_SIZE)/**
* Validates and sanitizes a phone number
* @param phoneNumber - The phone number to validate
* @returns PhoneValidationResult object with validation details
*/
validateAndSanitize(phoneNumber: string): PhoneValidationResult {
// Implementation
}
Run tests:
pnpm test
Run tests with coverage:
pnpm run test:cov
This package is ready to be published to NPM. See the publishing guides:
pnpm login
pnpm publish --access public
Users can then install it:
pnpm add @numsy
name,phone,address
John Doe,9876543210,Mumbai
Jane Smith,98765-43210,Delhi
Bob Wilson,+91 9876543210,Bangalore
valid_numbers.csv:
name,phone,address,originalPhone,sanitizedPhone,validationStatus
John Doe,9876543210,Mumbai,9876543210,9876543210,Valid
invalid_numbers.csv:
name,phone,address,originalPhone,sanitizedPhone,validationStatus,validationReason
Invalid User,12345,Chennai,12345,12345,Invalid,Invalid format - must be 10 digits
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License.
Your Name
For issues, questions, or contributions, please open an issue on GitHub.
Made with โค๏ธ using NestJS and TypeScript