soff-phone
v0.0.7~0.5KB CoreLightweight phone number validation and formatting for LATAM.
Features
Why use soff-phone?
- Tree-shakeable architecture
- Zero dependencies
- Mobile & Landline validation
- E.164 formatting support
- Type-safe interfaces
Installation
Add to your project
npm install soff-phoneUsage
import { validate } from 'soff-phone/co';
// Validate mobile number
const mobile = validate('3001234567');
console.log(mobile);
// Output:
// {
// isValid: true,
// type: 'mobile',
// formatted: '3001234567'
// }
// Validate landline (new format)
const landline = validate('6011234567');
console.log(landline);
// Output:
// {
// isValid: true,
// type: 'landline',
// formatted: '6011234567'
// }
// Format to E.164
const e164 = validate('3001234567', { format: 'e164' });
console.log(e164.formatted); // +573001234567