@astral/validations 2.7.1 → 2.7.3
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/compose/compose.js +1 -5
- package/compose/index.js +1 -17
- package/composeSome/composeSome.js +1 -5
- package/composeSome/index.js +1 -17
- package/constants.js +2 -5
- package/createRule/createRule.js +1 -5
- package/createRule/index.js +1 -17
- package/index.js +19 -35
- package/isDate/index.js +1 -17
- package/isDate/isDate.js +5 -8
- package/isEmail/index.js +1 -17
- package/isEmail/isEmail.js +8 -11
- package/isINNIP/index.js +1 -17
- package/isINNIP/isINNIP.js +5 -8
- package/isINNUL/index.js +1 -17
- package/isINNUL/isINNUL.js +5 -8
- package/isMaxLength/index.js +1 -5
- package/isMaxLength/isMaxLength.js +10 -17
- package/isMaxValue/index.js +1 -5
- package/isMaxValue/isMaxValue.js +9 -13
- package/isMaybeNumber/index.js +1 -17
- package/isMaybeNumber/isMaybeNumber.js +7 -10
- package/isMinLength/index.js +1 -17
- package/isMinLength/isMinLength.js +9 -16
- package/isMinValue/index.js +1 -5
- package/isMinValue/isMinValue.js +9 -13
- package/isMobilePhone/index.js +1 -17
- package/isMobilePhone/isMobilePhone.js +5 -8
- package/isOGRNIP/index.js +1 -17
- package/isOGRNIP/isOGRNIP.js +5 -8
- package/isOGRNUL/index.js +1 -17
- package/isOGRNUL/isOGRNUL.js +5 -8
- package/isRequired/index.js +1 -17
- package/isRequired/isRequired.js +5 -11
- package/isSNILS/index.js +1 -17
- package/isSNILS/isSNILS.js +5 -8
- package/package.json +5 -8
- package/types.js +1 -2
- package/utils/index.js +1 -17
- package/utils/isEmptyString.js +1 -5
- package/yupAdapter/index.js +1 -17
- package/yupAdapter/yupAdapter.js +1 -5
- package/esm/compose/compose.d.ts +0 -7
- package/esm/compose/compose.js +0 -6
- package/esm/compose/index.d.ts +0 -1
- package/esm/compose/index.js +0 -1
- package/esm/composeSome/composeSome.d.ts +0 -8
- package/esm/composeSome/composeSome.js +0 -25
- package/esm/composeSome/index.d.ts +0 -1
- package/esm/composeSome/index.js +0 -1
- package/esm/constants.d.ts +0 -2
- package/esm/constants.js +0 -2
- package/esm/createRule/createRule.d.ts +0 -14
- package/esm/createRule/createRule.js +0 -12
- package/esm/createRule/index.d.ts +0 -1
- package/esm/createRule/index.js +0 -1
- package/esm/index.d.ts +0 -19
- package/esm/index.js +0 -19
- package/esm/isDate/index.d.ts +0 -1
- package/esm/isDate/index.js +0 -1
- package/esm/isDate/isDate.d.ts +0 -10
- package/esm/isDate/isDate.js +0 -23
- package/esm/isEmail/index.d.ts +0 -1
- package/esm/isEmail/index.js +0 -1
- package/esm/isEmail/isEmail.d.ts +0 -13
- package/esm/isEmail/isEmail.js +0 -25
- package/esm/isINNIP/index.d.ts +0 -1
- package/esm/isINNIP/index.js +0 -1
- package/esm/isINNIP/isINNIP.d.ts +0 -10
- package/esm/isINNIP/isINNIP.js +0 -39
- package/esm/isINNUL/index.d.ts +0 -1
- package/esm/isINNUL/index.js +0 -1
- package/esm/isINNUL/isINNUL.d.ts +0 -10
- package/esm/isINNUL/isINNUL.js +0 -34
- package/esm/isMaxLength/index.d.ts +0 -1
- package/esm/isMaxLength/index.js +0 -1
- package/esm/isMaxLength/isMaxLength.d.ts +0 -18
- package/esm/isMaxLength/isMaxLength.js +0 -34
- package/esm/isMaxValue/index.d.ts +0 -1
- package/esm/isMaxValue/index.js +0 -1
- package/esm/isMaxValue/isMaxValue.d.ts +0 -17
- package/esm/isMaxValue/isMaxValue.js +0 -35
- package/esm/isMaybeNumber/index.d.ts +0 -1
- package/esm/isMaybeNumber/index.js +0 -1
- package/esm/isMaybeNumber/isMaybeNumber.d.ts +0 -10
- package/esm/isMaybeNumber/isMaybeNumber.js +0 -23
- package/esm/isMinLength/index.d.ts +0 -1
- package/esm/isMinLength/index.js +0 -1
- package/esm/isMinLength/isMinLength.d.ts +0 -18
- package/esm/isMinLength/isMinLength.js +0 -34
- package/esm/isMinValue/index.d.ts +0 -1
- package/esm/isMinValue/index.js +0 -1
- package/esm/isMinValue/isMinValue.d.ts +0 -17
- package/esm/isMinValue/isMinValue.js +0 -35
- package/esm/isMobilePhone/index.d.ts +0 -1
- package/esm/isMobilePhone/index.js +0 -1
- package/esm/isMobilePhone/isMobilePhone.d.ts +0 -10
- package/esm/isMobilePhone/isMobilePhone.js +0 -20
- package/esm/isOGRNIP/index.d.ts +0 -1
- package/esm/isOGRNIP/index.js +0 -1
- package/esm/isOGRNIP/isOGRNIP.d.ts +0 -10
- package/esm/isOGRNIP/isOGRNIP.js +0 -26
- package/esm/isOGRNUL/index.d.ts +0 -1
- package/esm/isOGRNUL/index.js +0 -1
- package/esm/isOGRNUL/isOGRNUL.d.ts +0 -10
- package/esm/isOGRNUL/isOGRNUL.js +0 -26
- package/esm/isRequired/index.d.ts +0 -1
- package/esm/isRequired/index.js +0 -1
- package/esm/isRequired/isRequired.d.ts +0 -11
- package/esm/isRequired/isRequired.js +0 -23
- package/esm/isSNILS/index.d.ts +0 -1
- package/esm/isSNILS/index.js +0 -1
- package/esm/isSNILS/isSNILS.d.ts +0 -10
- package/esm/isSNILS/isSNILS.js +0 -62
- package/esm/types.d.ts +0 -4
- package/esm/types.js +0 -1
- package/esm/utils/index.d.ts +0 -1
- package/esm/utils/index.js +0 -1
- package/esm/utils/isEmptyString.d.ts +0 -4
- package/esm/utils/isEmptyString.js +0 -6
- package/esm/yupAdapter/index.d.ts +0 -1
- package/esm/yupAdapter/index.js +0 -1
- package/esm/yupAdapter/yupAdapter.d.ts +0 -8
- package/esm/yupAdapter/yupAdapter.js +0 -11
package/isMobilePhone/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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);
|
1
|
+
export * from './isMobilePhone';
|
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_MOBILE_PHONE_DEFAULT_MESSAGE = 'Некорректный номер телефона';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_MOBILE_PHONE_DEFAULT_MESSAGE = 'Некорректный номер телефона';
|
7
4
|
const MOBILE_PHONE_REGEX = /^(79)\d{9}$/;
|
8
5
|
/**
|
9
6
|
* @description Проверяет валиден ли мобильный телефон
|
10
7
|
* @example isMobilePhone()('79999999999');
|
11
8
|
*/
|
12
|
-
|
13
|
-
if (
|
9
|
+
export const isMobilePhone = createRule(({ message = IS_MOBILE_PHONE_DEFAULT_MESSAGE } = {}) => (value) => {
|
10
|
+
if (isEmptyString(value)) {
|
14
11
|
return undefined;
|
15
12
|
}
|
16
13
|
if (typeof value === 'string') {
|
package/isOGRNIP/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./isOGRNIP"), exports);
|
1
|
+
export * from './isOGRNIP';
|
package/isOGRNIP/isOGRNIP.js
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_OGRNIP_DEFAULT_MESSAGE = 'Некорректный ОГРН ИП';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_OGRNIP_DEFAULT_MESSAGE = 'Некорректный ОГРН ИП';
|
7
4
|
const OGRNIP_LENGTH = 15;
|
8
5
|
/**
|
9
6
|
* @description Проверяет валиден ли ОРГН ИП
|
10
7
|
* @example isOGRNIP()('7728168971');
|
11
8
|
*/
|
12
|
-
|
13
|
-
if (
|
9
|
+
export const isOGRNIP = createRule(({ message = IS_OGRNIP_DEFAULT_MESSAGE } = {}) => (value) => {
|
10
|
+
if (isEmptyString(value)) {
|
14
11
|
return undefined;
|
15
12
|
}
|
16
13
|
if (typeof value === 'string') {
|
package/isOGRNUL/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./isOGRNUL"), exports);
|
1
|
+
export * from './isOGRNUL';
|
package/isOGRNUL/isOGRNUL.js
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_OGRNUL_DEFAULT_MESSAGE = 'Некорректный ОГРН ЮЛ';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_OGRNUL_DEFAULT_MESSAGE = 'Некорректный ОГРН ЮЛ';
|
7
4
|
const OGRNUL_LENGTH = 13;
|
8
5
|
/**
|
9
6
|
* @description Проверяет валиден ли ОРГН ЮЛ
|
10
7
|
* @example isOGRNUL()('7728168971');
|
11
8
|
*/
|
12
|
-
|
13
|
-
if (
|
9
|
+
export const isOGRNUL = createRule(({ message = IS_OGRNUL_DEFAULT_MESSAGE } = {}) => (value) => {
|
10
|
+
if (isEmptyString(value)) {
|
14
11
|
return undefined;
|
15
12
|
}
|
16
13
|
if (typeof value === 'string') {
|
package/isRequired/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./isRequired"), exports);
|
1
|
+
export * from './isRequired';
|
package/isRequired/isRequired.js
CHANGED
@@ -1,18 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isRequired = exports.REQUIRED_RULE_DEFAULT_MESSAGE = void 0;
|
7
|
-
const lodash_isempty_1 = __importDefault(require("lodash.isempty"));
|
8
|
-
const createRule_1 = require("../createRule");
|
9
|
-
exports.REQUIRED_RULE_DEFAULT_MESSAGE = 'Не заполнено';
|
1
|
+
import isEmpty from 'lodash.isempty';
|
2
|
+
import { createRule } from '../createRule';
|
3
|
+
export const REQUIRED_RULE_DEFAULT_MESSAGE = 'Не заполнено';
|
10
4
|
/**
|
11
5
|
* @description Проверяет присутсвует ли value
|
12
6
|
* @example isRequired();
|
13
7
|
* @example isRequired('ИНН обязателен');
|
14
8
|
*/
|
15
|
-
|
9
|
+
export const isRequired = createRule(({ message = REQUIRED_RULE_DEFAULT_MESSAGE } = {}) => (value) => {
|
16
10
|
if (typeof value === 'number' || value instanceof Date) {
|
17
11
|
return undefined;
|
18
12
|
}
|
@@ -22,7 +16,7 @@ exports.isRequired = (0, createRule_1.createRule)(({ message = exports.REQUIRED_
|
|
22
16
|
if (typeof value === 'boolean') {
|
23
17
|
return value ? undefined : message;
|
24
18
|
}
|
25
|
-
if (!(
|
19
|
+
if (!isEmpty(value)) {
|
26
20
|
return undefined;
|
27
21
|
}
|
28
22
|
return message;
|
package/isSNILS/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./isSNILS"), exports);
|
1
|
+
export * from './isSNILS';
|
package/isSNILS/isSNILS.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_SNILS_DEFAULT_MESSAGE = 'Некорректный СНИЛС';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_SNILS_DEFAULT_MESSAGE = 'Некорректный СНИЛС';
|
7
4
|
const RESTRICTED_VALUES = ['00000000000'];
|
8
5
|
const DEFAULT_CHECKED_SUM = [0, 100, 101];
|
9
6
|
const removeSpecialCharacters = (value) => {
|
@@ -23,8 +20,8 @@ const compareCheckSum = (calculatedCheckSum, checkSum) => {
|
|
23
20
|
* @description Проверяет валиден ли СНИЛС
|
24
21
|
* @example isSNILS()('95145370513');
|
25
22
|
*/
|
26
|
-
|
27
|
-
if (
|
23
|
+
export const isSNILS = createRule(({ message = IS_SNILS_DEFAULT_MESSAGE } = {}) => (value) => {
|
24
|
+
if (isEmptyString(value)) {
|
28
25
|
return undefined;
|
29
26
|
}
|
30
27
|
if (typeof value !== 'string') {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@astral/validations",
|
3
|
-
"version": "2.7.
|
4
|
-
"browser": "./
|
3
|
+
"version": "2.7.3",
|
4
|
+
"browser": "./index.js",
|
5
5
|
"main": "./index.js",
|
6
6
|
"dependencies": {
|
7
7
|
"lodash.isempty": "^4.4.0"
|
@@ -17,12 +17,9 @@
|
|
17
17
|
},
|
18
18
|
"keywords": [],
|
19
19
|
"sideEffects": false,
|
20
|
-
"types": "./
|
21
|
-
"module": "./
|
20
|
+
"types": "./index.d.ts",
|
21
|
+
"module": "./index.js",
|
22
22
|
"exports": {
|
23
|
-
".":
|
24
|
-
"import": "./esm/index.js",
|
25
|
-
"require": "./index.js"
|
26
|
-
}
|
23
|
+
".": "./index.js"
|
27
24
|
}
|
28
25
|
}
|
package/types.js
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
1
|
+
export {};
|
package/utils/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./isEmptyString"), exports);
|
1
|
+
export * from './isEmptyString';
|
package/utils/isEmptyString.js
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isEmptyString = void 0;
|
4
1
|
/**
|
5
2
|
* @description Используется в правилах валидации для проверки того, что проверяемое значение еще не указано
|
6
3
|
*/
|
7
|
-
const isEmptyString = (value) => {
|
4
|
+
export const isEmptyString = (value) => {
|
8
5
|
return value === '';
|
9
6
|
};
|
10
|
-
exports.isEmptyString = isEmptyString;
|
package/yupAdapter/index.js
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
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("./yupAdapter"), exports);
|
1
|
+
export * from './yupAdapter';
|
package/yupAdapter/yupAdapter.js
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.yupAdapter = void 0;
|
4
1
|
/**
|
5
2
|
* @description Адаптирует правило созданное createRule к интерфейсу yup
|
6
3
|
* @example yupAdapter(isMinLength(22))('word')
|
7
4
|
*/
|
8
|
-
const yupAdapter = (rule) => (value) => {
|
5
|
+
export const yupAdapter = (rule) => (value) => {
|
9
6
|
const error = rule(value);
|
10
7
|
if (!error) {
|
11
8
|
return false;
|
12
9
|
}
|
13
10
|
return error;
|
14
11
|
};
|
15
|
-
exports.yupAdapter = yupAdapter;
|
package/esm/compose/compose.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import { InitializedRule, ValidationResult } from '../types';
|
2
|
-
/**
|
3
|
-
* @description Объединяет переданные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
4
|
-
* @example compose(isRequired(), isEmail());
|
5
|
-
* @example compose(isRequired(), compose(isIncludeDot(), isIncludeComma()));
|
6
|
-
*/
|
7
|
-
export declare const compose: (...rules: InitializedRule[]) => (value: unknown) => ValidationResult;
|
package/esm/compose/compose.js
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @description Объединяет переданные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
3
|
-
* @example compose(isRequired(), isEmail());
|
4
|
-
* @example compose(isRequired(), compose(isIncludeDot(), isIncludeComma()));
|
5
|
-
*/
|
6
|
-
export const compose = (...rules) => (value) => rules.reduce((result, rule) => result || rule(value), undefined);
|
package/esm/compose/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './compose';
|
package/esm/compose/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './compose';
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { InitializedRule, ValidationResult } from '../types';
|
2
|
-
/**
|
3
|
-
* @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил.
|
4
|
-
* Выполняет правила слева направо. Возвращает текст первой ошибки, если все правила выполнены с ошибкой
|
5
|
-
* @example composeSome(isIncludeDot(), isIncludeComma());
|
6
|
-
* @example compose(isRequired(), composeSome(isIncludeDot(), isIncludeComma()));
|
7
|
-
*/
|
8
|
-
export declare const composeSome: (...rules: InitializedRule[]) => (value: unknown) => ValidationResult;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил.
|
3
|
-
* Выполняет правила слева направо. Возвращает текст первой ошибки, если все правила выполнены с ошибкой
|
4
|
-
* @example composeSome(isIncludeDot(), isIncludeComma());
|
5
|
-
* @example compose(isRequired(), composeSome(isIncludeDot(), isIncludeComma()));
|
6
|
-
*/
|
7
|
-
export const composeSome = (...rules) => (value) => {
|
8
|
-
const errors = rules.reduce((errorsAcc, rule) => {
|
9
|
-
const error = rule(value);
|
10
|
-
if (Array.isArray(error) && error.length > 0) {
|
11
|
-
errorsAcc.push(...error);
|
12
|
-
}
|
13
|
-
if (typeof error === 'string') {
|
14
|
-
errorsAcc.push(error);
|
15
|
-
}
|
16
|
-
return errorsAcc;
|
17
|
-
}, []);
|
18
|
-
if (!errors.length) {
|
19
|
-
return undefined;
|
20
|
-
}
|
21
|
-
if (errors.length < rules.length) {
|
22
|
-
return undefined;
|
23
|
-
}
|
24
|
-
return errors[0];
|
25
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './composeSome';
|
package/esm/composeSome/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './composeSome';
|
package/esm/constants.d.ts
DELETED
package/esm/constants.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { Rule } from '../types';
|
2
|
-
/**
|
3
|
-
* @description Фабрика по созданию правил валидации.
|
4
|
-
*/
|
5
|
-
export declare function createRule<Params extends object, RequiredParams extends true>(creator: Rule<Params & {
|
6
|
-
exclude?: (value: unknown) => boolean;
|
7
|
-
}, RequiredParams>): Rule<Params & {
|
8
|
-
exclude?: (value: unknown) => boolean;
|
9
|
-
}, RequiredParams>;
|
10
|
-
export declare function createRule<Params extends object, RequiredParams extends false>(creator: Rule<Params & {
|
11
|
-
exclude?: (value: unknown) => boolean;
|
12
|
-
}, RequiredParams>): Rule<Params & {
|
13
|
-
exclude?: (value: unknown) => boolean;
|
14
|
-
}, RequiredParams>;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
// Реализована перегрузка, поэтому используется any
|
2
|
-
// eslint-disable-next-line
|
3
|
-
export function createRule(creator) {
|
4
|
-
// eslint-disable-next-line
|
5
|
-
return (params) => (value) => {
|
6
|
-
var _a;
|
7
|
-
if ((_a = params === null || params === void 0 ? void 0 : params.exclude) === null || _a === void 0 ? void 0 : _a.call(params, value)) {
|
8
|
-
return undefined;
|
9
|
-
}
|
10
|
-
return creator(params)(value);
|
11
|
-
};
|
12
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './createRule';
|
package/esm/createRule/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './createRule';
|
package/esm/index.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
export * from './createRule';
|
2
|
-
export * from './yupAdapter';
|
3
|
-
export * from './compose';
|
4
|
-
export * from './isRequired';
|
5
|
-
export * from './types';
|
6
|
-
export * from './isINNUL';
|
7
|
-
export * from './isINNIP';
|
8
|
-
export * from './isMobilePhone';
|
9
|
-
export * from './isOGRNIP';
|
10
|
-
export * from './isOGRNUL';
|
11
|
-
export * from './isMinLength';
|
12
|
-
export * from './isMaxLength';
|
13
|
-
export * from './isMaxValue';
|
14
|
-
export * from './isMinValue';
|
15
|
-
export * from './isMaybeNumber';
|
16
|
-
export * from './isDate';
|
17
|
-
export * from './isSNILS';
|
18
|
-
export * from './composeSome';
|
19
|
-
export * from './isEmail';
|
package/esm/index.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
export * from './createRule';
|
2
|
-
export * from './yupAdapter';
|
3
|
-
export * from './compose';
|
4
|
-
export * from './isRequired';
|
5
|
-
export * from './types';
|
6
|
-
export * from './isINNUL';
|
7
|
-
export * from './isINNIP';
|
8
|
-
export * from './isMobilePhone';
|
9
|
-
export * from './isOGRNIP';
|
10
|
-
export * from './isOGRNUL';
|
11
|
-
export * from './isMinLength';
|
12
|
-
export * from './isMaxLength';
|
13
|
-
export * from './isMaxValue';
|
14
|
-
export * from './isMinValue';
|
15
|
-
export * from './isMaybeNumber';
|
16
|
-
export * from './isDate';
|
17
|
-
export * from './isSNILS';
|
18
|
-
export * from './composeSome';
|
19
|
-
export * from './isEmail';
|
package/esm/isDate/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isDate';
|
package/esm/isDate/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isDate';
|
package/esm/isDate/isDate.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
export declare const IS_DATE_RULE_DEFAULT_MESSAGE = "\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442 \u0434\u0430\u0442\u044B";
|
2
|
-
/**
|
3
|
-
* @description Проверяет валидна ли дата
|
4
|
-
* @example isDate()('2011-11-12');
|
5
|
-
*/
|
6
|
-
export declare const isDate: (params?: ({
|
7
|
-
message?: string | undefined;
|
8
|
-
} & {
|
9
|
-
exclude?: ((value: unknown) => boolean) | undefined;
|
10
|
-
}) | undefined) => import("..").InitializedRule;
|
package/esm/isDate/isDate.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import { createRule } from '../createRule';
|
2
|
-
import { isEmptyString } from '../utils';
|
3
|
-
export const IS_DATE_RULE_DEFAULT_MESSAGE = 'Неверный формат даты';
|
4
|
-
/**
|
5
|
-
* @description Проверяет валидна ли дата
|
6
|
-
* @example isDate()('2011-11-12');
|
7
|
-
*/
|
8
|
-
export const isDate = createRule(({ message = IS_DATE_RULE_DEFAULT_MESSAGE } = {}) => (value) => {
|
9
|
-
if (isEmptyString(value)) {
|
10
|
-
return undefined;
|
11
|
-
}
|
12
|
-
if (typeof value === 'string') {
|
13
|
-
const date = new Date(value);
|
14
|
-
if (!isNaN(date.getTime())) {
|
15
|
-
return undefined;
|
16
|
-
}
|
17
|
-
return message;
|
18
|
-
}
|
19
|
-
if (value instanceof Date && !isNaN(value.getTime())) {
|
20
|
-
return undefined;
|
21
|
-
}
|
22
|
-
return message;
|
23
|
-
});
|
package/esm/isEmail/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isEmail';
|
package/esm/isEmail/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isEmail';
|
package/esm/isEmail/isEmail.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
export declare const EMAIL_MAX_LENGTH = 256;
|
2
|
-
export declare const DEFAULT_ERROR_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 E-mail";
|
3
|
-
export declare const INVALID_LENGTH_ERROR_MESSAGE = "E-mail \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0434\u043B\u0438\u043D\u043D\u044B\u0439";
|
4
|
-
/**
|
5
|
-
* @description Проверяет валиден ли email
|
6
|
-
* @example isEmail()('test@example.com');
|
7
|
-
*/
|
8
|
-
export declare const isEmail: (params?: ({
|
9
|
-
message?: string | undefined;
|
10
|
-
invalidLengthMessage?: string | undefined;
|
11
|
-
} & {
|
12
|
-
exclude?: ((value: unknown) => boolean) | undefined;
|
13
|
-
}) | undefined) => import("..").InitializedRule;
|
package/esm/isEmail/isEmail.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { createRule } from '../createRule';
|
2
|
-
import { isEmptyString } from '../utils';
|
3
|
-
const EMAIL_REGEXP = /^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,}$/;
|
4
|
-
export const EMAIL_MAX_LENGTH = 256;
|
5
|
-
export const DEFAULT_ERROR_MESSAGE = 'Некорректный E-mail';
|
6
|
-
export const INVALID_LENGTH_ERROR_MESSAGE = 'E-mail слишком длинный';
|
7
|
-
/**
|
8
|
-
* @description Проверяет валиден ли email
|
9
|
-
* @example isEmail()('test@example.com');
|
10
|
-
*/
|
11
|
-
export const isEmail = createRule(({ message = DEFAULT_ERROR_MESSAGE, invalidLengthMessage = INVALID_LENGTH_ERROR_MESSAGE, } = {}) => (value) => {
|
12
|
-
if (typeof value !== 'string') {
|
13
|
-
return message;
|
14
|
-
}
|
15
|
-
if (isEmptyString(value)) {
|
16
|
-
return undefined;
|
17
|
-
}
|
18
|
-
if (!EMAIL_REGEXP.test(value)) {
|
19
|
-
return message;
|
20
|
-
}
|
21
|
-
if (value.length > EMAIL_MAX_LENGTH) {
|
22
|
-
return invalidLengthMessage;
|
23
|
-
}
|
24
|
-
return undefined;
|
25
|
-
});
|
package/esm/isINNIP/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isINNIP';
|
package/esm/isINNIP/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isINNIP';
|
package/esm/isINNIP/isINNIP.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
export declare const IS_INNIP_DEFAULT_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0418\u041D\u041D \u0418\u041F";
|
2
|
-
/**
|
3
|
-
* @description Проверяет валиден ли ИНН ИП
|
4
|
-
* @example isINNIP()('384212952720');
|
5
|
-
*/
|
6
|
-
export declare const isINNIP: (params?: ({
|
7
|
-
message?: string | undefined;
|
8
|
-
} & {
|
9
|
-
exclude?: ((value: unknown) => boolean) | undefined;
|
10
|
-
}) | undefined) => import("..").InitializedRule;
|
package/esm/isINNIP/isINNIP.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import { createRule } from '../createRule';
|
2
|
-
import { isEmptyString } from '../utils';
|
3
|
-
export const IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ИП';
|
4
|
-
const INNIP_LENGTH = 12;
|
5
|
-
const FIRST_INN_UL_DECODING = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
|
6
|
-
const SECOND_INN_UL_DECODING = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
|
7
|
-
const calcFirstCheckSumForInnUl = (arrSymbols) => (arrSymbols
|
8
|
-
.slice(0, -2)
|
9
|
-
.reduce((sum, symbol, index) => FIRST_INN_UL_DECODING[index] * Number(symbol) + sum, 0) %
|
10
|
-
11) %
|
11
|
-
10;
|
12
|
-
const calcSecondCheckSumForInnUl = (arrSymbols) => (arrSymbols
|
13
|
-
.slice(0, -1)
|
14
|
-
.reduce((sum, symbol, index) => SECOND_INN_UL_DECODING[index] * Number(symbol) + sum, 0) %
|
15
|
-
11) %
|
16
|
-
10;
|
17
|
-
/**
|
18
|
-
* @description Проверяет валиден ли ИНН ИП
|
19
|
-
* @example isINNIP()('384212952720');
|
20
|
-
*/
|
21
|
-
export const isINNIP = createRule(({ message = IS_INNIP_DEFAULT_MESSAGE } = {}) => (value) => {
|
22
|
-
if (isEmptyString(value)) {
|
23
|
-
return undefined;
|
24
|
-
}
|
25
|
-
if (typeof value === 'string') {
|
26
|
-
if (value.length !== INNIP_LENGTH) {
|
27
|
-
return message;
|
28
|
-
}
|
29
|
-
const arrSymbols = value.split('');
|
30
|
-
const firstChecksum = calcFirstCheckSumForInnUl(arrSymbols);
|
31
|
-
const secondChecksum = calcSecondCheckSumForInnUl(arrSymbols);
|
32
|
-
if (Number(value[10]) !== firstChecksum &&
|
33
|
-
Number(value[11]) !== secondChecksum) {
|
34
|
-
return message;
|
35
|
-
}
|
36
|
-
return undefined;
|
37
|
-
}
|
38
|
-
return message;
|
39
|
-
});
|
package/esm/isINNUL/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isINNUL';
|
package/esm/isINNUL/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './isINNUL';
|