@astral/validations 1.22.0 → 1.23.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/esm/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './isRequired';
7
7
  export * from './types';
8
8
  export * from './isINNUL';
9
9
  export * from './isINNIP';
10
+ export * from './isMobilePhone';
10
11
  export * from './isOGRNIP';
11
12
  export * from './isOGRNUL';
12
13
  export * from './isMinLength';
package/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './isRequired';
7
7
  export * from './types';
8
8
  export * from './isINNUL';
9
9
  export * from './isINNIP';
10
+ export * from './isMobilePhone';
10
11
  export * from './isOGRNIP';
11
12
  export * from './isOGRNUL';
12
13
  export * from './isMinLength';
@@ -0,0 +1 @@
1
+ export * from './isMobilePhone';
@@ -0,0 +1 @@
1
+ export * from './isMobilePhone';
@@ -0,0 +1,10 @@
1
+ export declare const IS_MOBILE_PHONE_DEFAULT_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430";
2
+ /**
3
+ * @description Проверяет валиден ли мобильный телефон
4
+ * @example isMobilePhone()('79999999999');
5
+ */
6
+ export declare const isMobilePhone: (params?: ({
7
+ message?: string | undefined;
8
+ } & {
9
+ exclude?: ((value: unknown) => boolean) | undefined;
10
+ }) | undefined) => import("..").InitializedRule;
@@ -0,0 +1,20 @@
1
+ import { createRule } from '../createRule';
2
+ import { isEmptyString } from '../utils';
3
+ export const IS_MOBILE_PHONE_DEFAULT_MESSAGE = 'Некорректный номер телефона';
4
+ const MOBILE_PHONE_REGEX = /^(7)\d{10}$/;
5
+ /**
6
+ * @description Проверяет валиден ли мобильный телефон
7
+ * @example isMobilePhone()('79999999999');
8
+ */
9
+ export const isMobilePhone = createRule(({ message = IS_MOBILE_PHONE_DEFAULT_MESSAGE } = {}) => (value) => {
10
+ if (isEmptyString(value)) {
11
+ return undefined;
12
+ }
13
+ if (typeof value === 'string') {
14
+ if (!MOBILE_PHONE_REGEX.test(value)) {
15
+ return message;
16
+ }
17
+ return undefined;
18
+ }
19
+ return message;
20
+ });
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './isRequired';
7
7
  export * from './types';
8
8
  export * from './isINNUL';
9
9
  export * from './isINNIP';
10
+ export * from './isMobilePhone';
10
11
  export * from './isOGRNIP';
11
12
  export * from './isOGRNUL';
12
13
  export * from './isMinLength';
package/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./isRequired"), exports);
23
23
  __exportStar(require("./types"), exports);
24
24
  __exportStar(require("./isINNUL"), exports);
25
25
  __exportStar(require("./isINNIP"), exports);
26
+ __exportStar(require("./isMobilePhone"), exports);
26
27
  __exportStar(require("./isOGRNIP"), exports);
27
28
  __exportStar(require("./isOGRNUL"), exports);
28
29
  __exportStar(require("./isMinLength"), exports);
@@ -0,0 +1 @@
1
+ export * from './isMobilePhone';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./isMobilePhone"), exports);
@@ -0,0 +1,10 @@
1
+ export declare const IS_MOBILE_PHONE_DEFAULT_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430";
2
+ /**
3
+ * @description Проверяет валиден ли мобильный телефон
4
+ * @example isMobilePhone()('79999999999');
5
+ */
6
+ export declare const isMobilePhone: (params?: ({
7
+ message?: string | undefined;
8
+ } & {
9
+ exclude?: ((value: unknown) => boolean) | undefined;
10
+ }) | undefined) => import("..").InitializedRule;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMobilePhone = exports.IS_MOBILE_PHONE_DEFAULT_MESSAGE = void 0;
4
+ const createRule_1 = require("../createRule");
5
+ const utils_1 = require("../utils");
6
+ exports.IS_MOBILE_PHONE_DEFAULT_MESSAGE = 'Некорректный номер телефона';
7
+ const MOBILE_PHONE_REGEX = /^(7)\d{10}$/;
8
+ /**
9
+ * @description Проверяет валиден ли мобильный телефон
10
+ * @example isMobilePhone()('79999999999');
11
+ */
12
+ exports.isMobilePhone = (0, createRule_1.createRule)(({ message = exports.IS_MOBILE_PHONE_DEFAULT_MESSAGE } = {}) => (value) => {
13
+ if ((0, utils_1.isEmptyString)(value)) {
14
+ return undefined;
15
+ }
16
+ if (typeof value === 'string') {
17
+ if (!MOBILE_PHONE_REGEX.test(value)) {
18
+ return message;
19
+ }
20
+ return undefined;
21
+ }
22
+ return message;
23
+ });
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dependencies": {
6
6
  "lodash.isempty": "^4.4.0"
7
7
  },
8
- "version": "1.22.0",
8
+ "version": "1.23.0",
9
9
  "author": "Astral.Soft",
10
10
  "license": "MIT",
11
11
  "repository": {