@karta.io/utils 0.33.3 → 0.33.5

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/index.cjs CHANGED
@@ -160,6 +160,8 @@ function getPaginationPages({
160
160
  }
161
161
 
162
162
  function parsePhone(phone) {
163
+ if (!phone || typeof phone !== "string")
164
+ return "";
163
165
  const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
164
166
  if (replacedPhone.length === 1 && replacedPhone !== "+") {
165
167
  return `+${replacedPhone}`;
@@ -530,6 +532,8 @@ function useLogger(scope, options) {
530
532
  }
531
533
 
532
534
  function validatePhone(rule, value) {
535
+ if (!value)
536
+ return true;
533
537
  const phoneNumber = libphonenumberJs.parsePhoneNumberFromString(value);
534
538
  return phoneNumber ? phoneNumber.isValid() : false;
535
539
  }
package/dist/index.d.ts CHANGED
@@ -69,7 +69,7 @@ declare function getPaginationPages({ count, limit, }: {
69
69
  limit: string | number;
70
70
  }): number;
71
71
 
72
- declare function parsePhone(phone: string): string;
72
+ declare function parsePhone(phone: string | null | undefined): string;
73
73
 
74
74
  type SnakelizeKeysProp = Record<string | number, any>;
75
75
  declare function snakelizeKeys(prop: SnakelizeKeysProp): SnakelizeKeysProp;
package/dist/index.mjs CHANGED
@@ -158,6 +158,8 @@ function getPaginationPages({
158
158
  }
159
159
 
160
160
  function parsePhone(phone) {
161
+ if (!phone || typeof phone !== "string")
162
+ return "";
161
163
  const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
162
164
  if (replacedPhone.length === 1 && replacedPhone !== "+") {
163
165
  return `+${replacedPhone}`;
@@ -528,6 +530,8 @@ function useLogger(scope, options) {
528
530
  }
529
531
 
530
532
  function validatePhone(rule, value) {
533
+ if (!value)
534
+ return true;
531
535
  const phoneNumber = parsePhoneNumberFromString(value);
532
536
  return phoneNumber ? phoneNumber.isValid() : false;
533
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karta.io/utils",
3
- "version": "0.33.3",
3
+ "version": "0.33.5",
4
4
  "description": "karta.io utils for admin and application",
5
5
  "author": "Vitaly Blokhin <karambafe@gmail.com>",
6
6
  "homepage": "",
@@ -23,7 +23,7 @@
23
23
  "vue": "3.2.x"
24
24
  },
25
25
  "dependencies": {
26
- "@karta.io/common-data": "^0.33.3",
26
+ "@karta.io/common-data": "^0.33.5",
27
27
  "@vueuse/core": "9.13.0",
28
28
  "async-validator": "4.2.5",
29
29
  "dayjs": "1.11.7",