soff-phone 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ar-GEGiRgO-.d.cts → ar-CoG6alvv.d.cts} +1 -1
- package/dist/{ar-tFIt4w8t.d.ts → ar-DflcS_NX.d.ts} +1 -1
- package/dist/{br-DDdWmYiI.d.ts → br-DUpSkSAW.d.ts} +1 -1
- package/dist/{br-BT6qg54j.d.cts → br-wLM9wWJU.d.cts} +1 -1
- package/dist/{ca-DCSAnAM6.d.cts → ca-CrMz6MFF.d.cts} +1 -1
- package/dist/{ca-_dlgNQpK.d.ts → ca-DgJh2Fn8.d.ts} +1 -1
- package/dist/{cl-BnJa59XK.d.ts → cl-BlYnSeBu.d.ts} +1 -1
- package/dist/{cl-FomUh7u7.d.cts → cl-Bsw7oXO1.d.cts} +1 -1
- package/dist/{co-D3zWUbcg.d.ts → co-Ds64GC27.d.ts} +1 -1
- package/dist/{co-HLHZhdf-.d.cts → co-DsNqMeJC.d.cts} +1 -1
- package/dist/{cr-TYetkCTg.d.cts → cr-D1nfQd5a.d.cts} +1 -1
- package/dist/{cr-CkAZd-e7.d.ts → cr-DZo_UJeA.d.ts} +1 -1
- package/dist/{de-D-lK2VKQ.d.ts → de-B0lClAaa.d.ts} +1 -1
- package/dist/{de-l5sbcQdU.d.cts → de-D8Dy5ZLN.d.cts} +1 -1
- package/dist/{ec-CLItBhMX.d.ts → ec-DMEwGX4e.d.ts} +1 -1
- package/dist/{ec-G_GvdmHT.d.cts → ec-Dmvg9ZEu.d.cts} +1 -1
- package/dist/{es-C0cTzz5Q.d.ts → es-C9fnTkGA.d.ts} +1 -1
- package/dist/{es-DBWm_0BJ.d.cts → es-nCje-ks0.d.cts} +1 -1
- package/dist/{fr-BFsuh3v2.d.cts → fr-6elCkAaM.d.cts} +1 -1
- package/dist/{fr-BE6W1TEy.d.ts → fr-DhJ1s23l.d.ts} +1 -1
- package/dist/{gb-Dsiq1sFD.d.cts → gb-B25B912T.d.cts} +1 -1
- package/dist/{gb-Cvog8XpH.d.ts → gb-ehC5-Ys2.d.ts} +1 -1
- package/dist/{gt-CHOp9jw8.d.cts → gt-DKGg-Cq-.d.cts} +1 -1
- package/dist/{gt-BJOTX_KH.d.ts → gt-wRdkBW-T.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{it-Cvn0ckKc.d.cts → it-B434bcYI.d.cts} +1 -1
- package/dist/{it-DRkyyTTW.d.ts → it-fKUkvQel.d.ts} +1 -1
- package/dist/locales/ar.cjs +1 -1
- package/dist/locales/ar.cjs.map +1 -1
- package/dist/locales/ar.d.cts +1 -1
- package/dist/locales/ar.d.ts +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/br.cjs +1 -1
- package/dist/locales/br.cjs.map +1 -1
- package/dist/locales/br.d.cts +1 -1
- package/dist/locales/br.d.ts +1 -1
- package/dist/locales/br.js +1 -1
- package/dist/locales/br.js.map +1 -1
- package/dist/locales/ca.cjs +1 -1
- package/dist/locales/ca.cjs.map +1 -1
- package/dist/locales/ca.d.cts +1 -1
- package/dist/locales/ca.d.ts +1 -1
- package/dist/locales/ca.js +1 -1
- package/dist/locales/ca.js.map +1 -1
- package/dist/locales/cl.cjs +1 -1
- package/dist/locales/cl.cjs.map +1 -1
- package/dist/locales/cl.d.cts +1 -1
- package/dist/locales/cl.d.ts +1 -1
- package/dist/locales/cl.js +1 -1
- package/dist/locales/cl.js.map +1 -1
- package/dist/locales/co.cjs +1 -1
- package/dist/locales/co.cjs.map +1 -1
- package/dist/locales/co.d.cts +1 -1
- package/dist/locales/co.d.ts +1 -1
- package/dist/locales/co.js +1 -1
- package/dist/locales/co.js.map +1 -1
- package/dist/locales/cr.cjs +1 -1
- package/dist/locales/cr.cjs.map +1 -1
- package/dist/locales/cr.d.cts +1 -1
- package/dist/locales/cr.d.ts +1 -1
- package/dist/locales/cr.js +1 -1
- package/dist/locales/cr.js.map +1 -1
- package/dist/locales/de.cjs +1 -1
- package/dist/locales/de.cjs.map +1 -1
- package/dist/locales/de.d.cts +1 -1
- package/dist/locales/de.d.ts +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/ec.cjs +1 -1
- package/dist/locales/ec.cjs.map +1 -1
- package/dist/locales/ec.d.cts +1 -1
- package/dist/locales/ec.d.ts +1 -1
- package/dist/locales/ec.js +1 -1
- package/dist/locales/ec.js.map +1 -1
- package/dist/locales/es.cjs +1 -1
- package/dist/locales/es.cjs.map +1 -1
- package/dist/locales/es.d.cts +1 -1
- package/dist/locales/es.d.ts +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.cjs +1 -1
- package/dist/locales/fr.cjs.map +1 -1
- package/dist/locales/fr.d.cts +1 -1
- package/dist/locales/fr.d.ts +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/gb.cjs +1 -1
- package/dist/locales/gb.cjs.map +1 -1
- package/dist/locales/gb.d.cts +1 -1
- package/dist/locales/gb.d.ts +1 -1
- package/dist/locales/gb.js +1 -1
- package/dist/locales/gb.js.map +1 -1
- package/dist/locales/gt.cjs +1 -1
- package/dist/locales/gt.cjs.map +1 -1
- package/dist/locales/gt.d.cts +1 -1
- package/dist/locales/gt.d.ts +1 -1
- package/dist/locales/gt.js +1 -1
- package/dist/locales/gt.js.map +1 -1
- package/dist/locales/it.cjs +1 -1
- package/dist/locales/it.cjs.map +1 -1
- package/dist/locales/it.d.cts +1 -1
- package/dist/locales/it.d.ts +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/it.js.map +1 -1
- package/dist/locales/mx.cjs +1 -1
- package/dist/locales/mx.cjs.map +1 -1
- package/dist/locales/mx.d.cts +1 -1
- package/dist/locales/mx.d.ts +1 -1
- package/dist/locales/mx.js +1 -1
- package/dist/locales/mx.js.map +1 -1
- package/dist/locales/pa.cjs +1 -1
- package/dist/locales/pa.cjs.map +1 -1
- package/dist/locales/pa.d.cts +1 -1
- package/dist/locales/pa.d.ts +1 -1
- package/dist/locales/pa.js +1 -1
- package/dist/locales/pa.js.map +1 -1
- package/dist/locales/pe.cjs +1 -1
- package/dist/locales/pe.cjs.map +1 -1
- package/dist/locales/pe.d.cts +1 -1
- package/dist/locales/pe.d.ts +1 -1
- package/dist/locales/pe.js +1 -1
- package/dist/locales/pe.js.map +1 -1
- package/dist/locales/us.cjs +1 -1
- package/dist/locales/us.cjs.map +1 -1
- package/dist/locales/us.d.cts +1 -1
- package/dist/locales/us.d.ts +1 -1
- package/dist/locales/us.js +1 -1
- package/dist/locales/us.js.map +1 -1
- package/dist/locales/ve.cjs +1 -1
- package/dist/locales/ve.cjs.map +1 -1
- package/dist/locales/ve.d.cts +1 -1
- package/dist/locales/ve.d.ts +1 -1
- package/dist/locales/ve.js +1 -1
- package/dist/locales/ve.js.map +1 -1
- package/dist/{mx-CmkrNDw0.d.cts → mx-CIn7fuEP.d.cts} +1 -1
- package/dist/{mx-DkRS3Aa-.d.ts → mx-Cqj3ptQG.d.ts} +1 -1
- package/dist/{pa-BPfQzrBx.d.cts → pa-CJU86P1e.d.cts} +1 -1
- package/dist/{pa-Dyi3iuWW.d.ts → pa-DuqdSeyg.d.ts} +1 -1
- package/dist/{pe-B_5pgsR0.d.cts → pe-9EBUjBeW.d.cts} +1 -1
- package/dist/{pe-NCsXTXmc.d.ts → pe-DlAD1sw9.d.ts} +1 -1
- package/dist/{us-BaYu0g3a.d.cts → us-n2Rg22p3.d.cts} +1 -1
- package/dist/{us-KOpobREo.d.ts → us-oR1xJLtG.d.ts} +1 -1
- package/dist/{ve-BFLV2qGp.d.ts → ve-D0yC7va3.d.ts} +1 -1
- package/dist/{ve-BomxppQL.d.cts → ve-DZM4BR8e.d.cts} +1 -1
- package/package.json +6 -6
package/dist/locales/us.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../types-BCr040RT.cjs';
|
|
2
|
-
export { v as validate } from '../us-
|
|
2
|
+
export { v as validate } from '../us-n2Rg22p3.cjs';
|
package/dist/locales/us.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../types-BCr040RT.js';
|
|
2
|
-
export { v as validate } from '../us-
|
|
2
|
+
export { v as validate } from '../us-oR1xJLtG.js';
|
package/dist/locales/us.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(t){return t.replace(/\D/g,"")}function l(t,e){return `+${t}${e}`}function u(t){return function(n,o){let d=s(n),r=t.getNationalNumber(d),a=t.evaluateNationalNumber(r);if(!a.isValid)return a;let i=r;return o?.format==="e164"?i=l(t.countryCode,r):o?.format==="international"&&(i=`+${t.countryCode} ${r}`),{isValid:true,type:a.type,formatted:i}}}var p=u({countryCode:"1",getNationalNumber:t=>t.startsWith("1")&&t.length===11?t.slice(1):t,evaluateNationalNumber:t=>{if(t.length!==10)return {isValid:false,error:"Phone number must be 10 digits"};let e=t.substring(0,3);if(!/^[2-9][0-8][0-9]$/.test(e))return {isValid:false,error:"Invalid area code"};let n=t.substring(3,6);return /^[2-9]\d{2}$/.test(n)?{isValid:true,type:"unknown"}:{isValid:false,error:"Invalid exchange code"}}});export{p as validate};//# sourceMappingURL=us.js.map
|
|
2
2
|
//# sourceMappingURL=us.js.map
|
package/dist/locales/us.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils.ts","../../src/locales/us.ts"],"names":["cleanPhone","phone","formatE164","countryCode","
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils.ts","../../src/core/validator.ts","../../src/locales/us.ts"],"names":["cleanPhone","phone","formatE164","countryCode","createValidator","config","options","cleaned","national","evaluation","formatted","valid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,KAAA,CAAO,KAAA,CAAO,gCAAiC,CAAA,CAEnE,IAAMI,EAAWJ,CAAAA,CAAS,SAAA,CAAU,CAAA,CAAG,CAAC,EACxC,GAAI,CAAC,mBAAA,CAAoB,IAAA,CAAKI,CAAQ,CAAA,CACpC,OAAO,CAAE,OAAA,CAAS,MAAO,KAAA,CAAO,mBAAoB,EAEtD,IAAMC,CAAAA,CAAeL,EAAS,SAAA,CAAU,CAAA,CAAG,CAAC,CAAA,CAC5C,OAAK,cAAA,CAAe,IAAA,CAAKK,CAAY,CAAA,CAG9B,CAAE,QAAS,IAAA,CAAM,IAAA,CAAM,SAAU,CAAA,CAF/B,CAAE,OAAA,CAAS,KAAA,CAAO,MAAO,uBAAwB,CAG5D,CACF,CAAC","file":"us.js","sourcesContent":["export function cleanPhone(phone: string): string {\n return phone.replace(/\\D/g, '');\n}\n\nexport function formatE164(countryCode: string, phone: string): string {\n return `+${countryCode}${phone}`;\n}\n","import type { PhoneValidationResult, PhoneOptions } from './types.js';\nimport { cleanPhone, formatE164 } from './utils.js';\n\nexport interface PhoneValidatorConfig {\n countryCode: string;\n getNationalNumber: (cleaned: string) => string;\n evaluateNationalNumber: (\n national: string\n ) =>\n | { isValid: true; type: 'mobile' | 'landline' | 'unknown' }\n | { isValid: false; error: string };\n}\n\nexport function createValidator(config: PhoneValidatorConfig) {\n return function validate(phone: string, options?: PhoneOptions): PhoneValidationResult {\n const cleaned = cleanPhone(phone);\n const national = config.getNationalNumber(cleaned);\n\n const evaluation = config.evaluateNationalNumber(national);\n if (!evaluation.isValid) {\n return evaluation;\n }\n\n let formatted = national;\n if (options?.format === 'e164') {\n formatted = formatE164(config.countryCode, national);\n } else if (options?.format === 'international') {\n formatted = `+${config.countryCode} ${national}`;\n }\n\n return { isValid: true, type: evaluation.type, formatted };\n };\n}\n","import { createValidator } from '../core/validator.js';\n\nexport const validate = createValidator({\n countryCode: '1',\n getNationalNumber: (cleaned) =>\n cleaned.startsWith('1') && cleaned.length === 11 ? cleaned.slice(1) : cleaned,\n evaluateNationalNumber: (national) => {\n if (national.length !== 10) {\n return { isValid: false, error: 'Phone number must be 10 digits' };\n }\n const areaCode = national.substring(0, 3);\n if (!/^[2-9][0-8][0-9]$/.test(areaCode)) {\n return { isValid: false, error: 'Invalid area code' };\n }\n const exchangeCode = national.substring(3, 6);\n if (!/^[2-9]\\d{2}$/.test(exchangeCode)) {\n return { isValid: false, error: 'Invalid exchange code' };\n }\n return { isValid: true, type: 'unknown' };\n },\n});\n"]}
|
package/dist/locales/ve.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';function
|
|
1
|
+
'use strict';function o(t){return t.replace(/\D/g,"")}function l(t,i){return `+${t}${i}`}function s(t){return function(u,a){let d=o(u),e=t.getNationalNumber(d),r=t.evaluateNationalNumber(e);if(!r.isValid)return r;let n=e;return a?.format==="e164"?n=l(t.countryCode,e):a?.format==="international"&&(n=`+${t.countryCode} ${e}`),{isValid:true,type:r.type,formatted:n}}}var c=s({countryCode:"58",getNationalNumber:t=>t.startsWith("58")&&t.length>10?t.slice(2):t,evaluateNationalNumber:t=>t.length!==10?{isValid:false,error:"Phone number must be 10 digits"}:t.startsWith("4")?{isValid:true,type:"mobile"}:/^[2]/.test(t)?{isValid:true,type:"landline"}:{isValid:true,type:"unknown"}});exports.validate=c;//# sourceMappingURL=ve.cjs.map
|
|
2
2
|
//# sourceMappingURL=ve.cjs.map
|
package/dist/locales/ve.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils.ts","../../src/locales/ve.ts"],"names":["cleanPhone","phone","formatE164","countryCode","
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils.ts","../../src/core/validator.ts","../../src/locales/ve.ts"],"names":["cleanPhone","phone","formatE164","countryCode","createValidator","config","options","cleaned","national","evaluation","formatted","validate"],"mappings":"aAAO,SAASA,CAAAA,CAAWC,CAAAA,CAAuB,CAChD,OAAOA,EAAM,OAAA,C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AG,CAAA,CAClB,CAAE,OAAA,CAAS,KAAM,IAAA,CAAM,QAAS,CAAA,CAErC,MAAA,CAAO,IAAA,CAAKA,CAAQ,CAAA,CACf,CAAE,QAAS,IAAA,CAAM,IAAA,CAAM,UAAW,CAAA,CAEpC,CAAE,OAAA,CAAS,IAAA,CAAM,IAAA,CAAM,SAAU,CAE5C,CAAC","file":"ve.cjs","sourcesContent":["export function cleanPhone(phone: string): string {\n return phone.replace(/\\D/g, '');\n}\n\nexport function formatE164(countryCode: string, phone: string): string {\n return `+${countryCode}${phone}`;\n}\n","import type { PhoneValidationResult, PhoneOptions } from './types.js';\nimport { cleanPhone, formatE164 } from './utils.js';\n\nexport interface PhoneValidatorConfig {\n countryCode: string;\n getNationalNumber: (cleaned: string) => string;\n evaluateNationalNumber: (\n national: string\n ) =>\n | { isValid: true; type: 'mobile' | 'landline' | 'unknown' }\n | { isValid: false; error: string };\n}\n\nexport function createValidator(config: PhoneValidatorConfig) {\n return function validate(phone: string, options?: PhoneOptions): PhoneValidationResult {\n const cleaned = cleanPhone(phone);\n const national = config.getNationalNumber(cleaned);\n\n const evaluation = config.evaluateNationalNumber(national);\n if (!evaluation.isValid) {\n return evaluation;\n }\n\n let formatted = national;\n if (options?.format === 'e164') {\n formatted = formatE164(config.countryCode, national);\n } else if (options?.format === 'international') {\n formatted = `+${config.countryCode} ${national}`;\n }\n\n return { isValid: true, type: evaluation.type, formatted };\n };\n}\n","import { createValidator } from '../core/validator.js';\n\nexport const validate = createValidator({\n countryCode: '58',\n getNationalNumber: (cleaned) =>\n cleaned.startsWith('58') && cleaned.length > 10 ? cleaned.slice(2) : cleaned,\n evaluateNationalNumber: (national) => {\n if (national.length !== 10) {\n return { isValid: false, error: 'Phone number must be 10 digits' };\n }\n if (national.startsWith('4')) {\n return { isValid: true, type: 'mobile' };\n }\n if (/^[2]/.test(national)) {\n return { isValid: true, type: 'landline' };\n }\n return { isValid: true, type: 'unknown' };\n },\n});\n"]}
|
package/dist/locales/ve.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../types-BCr040RT.cjs';
|
|
2
|
-
export { a as validate } from '../ve-
|
|
2
|
+
export { a as validate } from '../ve-DZM4BR8e.cjs';
|
package/dist/locales/ve.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../types-BCr040RT.js';
|
|
2
|
-
export { a as validate } from '../ve-
|
|
2
|
+
export { a as validate } from '../ve-D0yC7va3.js';
|
package/dist/locales/ve.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function o(t){return t.replace(/\D/g,"")}function l(t,i){return `+${t}${i}`}function s(t){return function(u,a){let d=o(u),e=t.getNationalNumber(d),r=t.evaluateNationalNumber(e);if(!r.isValid)return r;let n=e;return a?.format==="e164"?n=l(t.countryCode,e):a?.format==="international"&&(n=`+${t.countryCode} ${e}`),{isValid:true,type:r.type,formatted:n}}}var c=s({countryCode:"58",getNationalNumber:t=>t.startsWith("58")&&t.length>10?t.slice(2):t,evaluateNationalNumber:t=>t.length!==10?{isValid:false,error:"Phone number must be 10 digits"}:t.startsWith("4")?{isValid:true,type:"mobile"}:/^[2]/.test(t)?{isValid:true,type:"landline"}:{isValid:true,type:"unknown"}});export{c as validate};//# sourceMappingURL=ve.js.map
|
|
2
2
|
//# sourceMappingURL=ve.js.map
|
package/dist/locales/ve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/utils.ts","../../src/locales/ve.ts"],"names":["cleanPhone","phone","formatE164","countryCode","
|
|
1
|
+
{"version":3,"sources":["../../src/core/utils.ts","../../src/core/validator.ts","../../src/locales/ve.ts"],"names":["cleanPhone","phone","formatE164","countryCode","createValidator","config","options","cleaned","national","evaluation","formatted","validate"],"mappings":"AAAO,SAASA,CAAAA,CAAWC,CAAAA,CAAuB,CAChD,OAAOA,EAAM,OAAA,CAAQ,KAAA,CAAO,EAAE,CAChC,CAEO,SAASC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AAA,CAAM,QAAS,CAAA,CAErC,MAAA,CAAO,IAAA,CAAKA,CAAQ,CAAA,CACf,CAAE,QAAS,IAAA,CAAM,IAAA,CAAM,UAAW,CAAA,CAEpC,CAAE,OAAA,CAAS,IAAA,CAAM,IAAA,CAAM,SAAU,CAE5C,CAAC","file":"ve.js","sourcesContent":["export function cleanPhone(phone: string): string {\n return phone.replace(/\\D/g, '');\n}\n\nexport function formatE164(countryCode: string, phone: string): string {\n return `+${countryCode}${phone}`;\n}\n","import type { PhoneValidationResult, PhoneOptions } from './types.js';\nimport { cleanPhone, formatE164 } from './utils.js';\n\nexport interface PhoneValidatorConfig {\n countryCode: string;\n getNationalNumber: (cleaned: string) => string;\n evaluateNationalNumber: (\n national: string\n ) =>\n | { isValid: true; type: 'mobile' | 'landline' | 'unknown' }\n | { isValid: false; error: string };\n}\n\nexport function createValidator(config: PhoneValidatorConfig) {\n return function validate(phone: string, options?: PhoneOptions): PhoneValidationResult {\n const cleaned = cleanPhone(phone);\n const national = config.getNationalNumber(cleaned);\n\n const evaluation = config.evaluateNationalNumber(national);\n if (!evaluation.isValid) {\n return evaluation;\n }\n\n let formatted = national;\n if (options?.format === 'e164') {\n formatted = formatE164(config.countryCode, national);\n } else if (options?.format === 'international') {\n formatted = `+${config.countryCode} ${national}`;\n }\n\n return { isValid: true, type: evaluation.type, formatted };\n };\n}\n","import { createValidator } from '../core/validator.js';\n\nexport const validate = createValidator({\n countryCode: '58',\n getNationalNumber: (cleaned) =>\n cleaned.startsWith('58') && cleaned.length > 10 ? cleaned.slice(2) : cleaned,\n evaluateNationalNumber: (national) => {\n if (national.length !== 10) {\n return { isValid: false, error: 'Phone number must be 10 digits' };\n }\n if (national.startsWith('4')) {\n return { isValid: true, type: 'mobile' };\n }\n if (/^[2]/.test(national)) {\n return { isValid: true, type: 'landline' };\n }\n return { isValid: true, type: 'unknown' };\n },\n});\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.cjs';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const mx_validate: typeof validate;
|
|
6
6
|
declare namespace mx {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.js';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const mx_validate: typeof validate;
|
|
6
6
|
declare namespace mx {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.cjs';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const pa_validate: typeof validate;
|
|
6
6
|
declare namespace pa {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.js';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const pa_validate: typeof validate;
|
|
6
6
|
declare namespace pa {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.cjs';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const pe_validate: typeof validate;
|
|
6
6
|
declare namespace pe {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.js';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const pe_validate: typeof validate;
|
|
6
6
|
declare namespace pe {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.cjs';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const us_validate: typeof validate;
|
|
6
6
|
declare namespace us {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.js';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const us_validate: typeof validate;
|
|
6
6
|
declare namespace us {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.js';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const ve_validate: typeof validate;
|
|
6
6
|
declare namespace ve {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as PhoneOptions, a as PhoneValidationResult } from './types-BCr040RT.cjs';
|
|
2
2
|
|
|
3
|
-
declare
|
|
3
|
+
declare const validate: (phone: string, options?: PhoneOptions) => PhoneValidationResult;
|
|
4
4
|
|
|
5
5
|
declare const ve_validate: typeof validate;
|
|
6
6
|
declare namespace ve {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soff-phone",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Lightweight phone number validation and formatting library for global markets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -270,15 +270,15 @@
|
|
|
270
270
|
"devDependencies": {
|
|
271
271
|
"@eslint/js": "^10.0.1",
|
|
272
272
|
"@soff/tsconfig": "*",
|
|
273
|
-
"@vitest/coverage-v8": "^4.1.
|
|
274
|
-
"eslint": "^10.
|
|
273
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
274
|
+
"eslint": "^10.7.0",
|
|
275
275
|
"eslint-config-prettier": "^10.1.8",
|
|
276
|
-
"globals": "^17.
|
|
277
|
-
"prettier": "^3.
|
|
276
|
+
"globals": "^17.7.0",
|
|
277
|
+
"prettier": "^3.9.5",
|
|
278
278
|
"rimraf": "^6.1.3",
|
|
279
279
|
"tsup": "^8.5.1",
|
|
280
280
|
"typescript": "^6.0.3",
|
|
281
|
-
"typescript-eslint": "^8.
|
|
281
|
+
"typescript-eslint": "^8.63.0",
|
|
282
282
|
"vitest": "^4.1.5"
|
|
283
283
|
},
|
|
284
284
|
"publishConfig": {
|