@astral/validations 2.7.2 → 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/compose/compose.js
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.compose = void 0;
|
4
1
|
/**
|
5
2
|
* @description Объединяет переданные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
6
3
|
* @example compose(isRequired(), isEmail());
|
7
4
|
* @example compose(isRequired(), compose(isIncludeDot(), isIncludeComma()));
|
8
5
|
*/
|
9
|
-
const compose = (...rules) => (value) => rules.reduce((result, rule) => result || rule(value), undefined);
|
10
|
-
exports.compose = compose;
|
6
|
+
export const compose = (...rules) => (value) => rules.reduce((result, rule) => result || rule(value), undefined);
|
package/compose/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("./compose"), exports);
|
1
|
+
export * from './compose';
|
@@ -1,13 +1,10 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.composeSome = void 0;
|
4
1
|
/**
|
5
2
|
* @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил.
|
6
3
|
* Выполняет правила слева направо. Возвращает текст первой ошибки, если все правила выполнены с ошибкой
|
7
4
|
* @example composeSome(isIncludeDot(), isIncludeComma());
|
8
5
|
* @example compose(isRequired(), composeSome(isIncludeDot(), isIncludeComma()));
|
9
6
|
*/
|
10
|
-
const composeSome = (...rules) => (value) => {
|
7
|
+
export const composeSome = (...rules) => (value) => {
|
11
8
|
const errors = rules.reduce((errorsAcc, rule) => {
|
12
9
|
const error = rule(value);
|
13
10
|
if (Array.isArray(error) && error.length > 0) {
|
@@ -26,4 +23,3 @@ const composeSome = (...rules) => (value) => {
|
|
26
23
|
}
|
27
24
|
return errors[0];
|
28
25
|
};
|
29
|
-
exports.composeSome = composeSome;
|
package/composeSome/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("./composeSome"), exports);
|
1
|
+
export * from './composeSome';
|
package/constants.js
CHANGED
@@ -1,5 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.CONTAINS_SPACES_REGEX = exports.INCORRECT_MESSAGE = void 0;
|
4
|
-
exports.INCORRECT_MESSAGE = 'Некорректное значение';
|
5
|
-
exports.CONTAINS_SPACES_REGEX = /\s/g;
|
1
|
+
export const INCORRECT_MESSAGE = 'Некорректное значение';
|
2
|
+
export const CONTAINS_SPACES_REGEX = /\s/g;
|
package/createRule/createRule.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createRule = void 0;
|
4
1
|
// Реализована перегрузка, поэтому используется any
|
5
2
|
// eslint-disable-next-line
|
6
|
-
function createRule(creator) {
|
3
|
+
export function createRule(creator) {
|
7
4
|
// eslint-disable-next-line
|
8
5
|
return (params) => (value) => {
|
9
6
|
var _a;
|
@@ -13,4 +10,3 @@ function createRule(creator) {
|
|
13
10
|
return creator(params)(value);
|
14
11
|
};
|
15
12
|
}
|
16
|
-
exports.createRule = createRule;
|
package/createRule/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("./createRule"), exports);
|
1
|
+
export * from './createRule';
|
package/index.js
CHANGED
@@ -1,35 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
__exportStar(require("./isRequired"), exports);
|
21
|
-
__exportStar(require("./types"), exports);
|
22
|
-
__exportStar(require("./isINNUL"), exports);
|
23
|
-
__exportStar(require("./isINNIP"), exports);
|
24
|
-
__exportStar(require("./isMobilePhone"), exports);
|
25
|
-
__exportStar(require("./isOGRNIP"), exports);
|
26
|
-
__exportStar(require("./isOGRNUL"), exports);
|
27
|
-
__exportStar(require("./isMinLength"), exports);
|
28
|
-
__exportStar(require("./isMaxLength"), exports);
|
29
|
-
__exportStar(require("./isMaxValue"), exports);
|
30
|
-
__exportStar(require("./isMinValue"), exports);
|
31
|
-
__exportStar(require("./isMaybeNumber"), exports);
|
32
|
-
__exportStar(require("./isDate"), exports);
|
33
|
-
__exportStar(require("./isSNILS"), exports);
|
34
|
-
__exportStar(require("./composeSome"), exports);
|
35
|
-
__exportStar(require("./isEmail"), exports);
|
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/isDate/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("./isDate"), exports);
|
1
|
+
export * from './isDate';
|
package/isDate/isDate.js
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_DATE_RULE_DEFAULT_MESSAGE = 'Неверный формат даты';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_DATE_RULE_DEFAULT_MESSAGE = 'Неверный формат даты';
|
7
4
|
/**
|
8
5
|
* @description Проверяет валидна ли дата
|
9
6
|
* @example isDate()('2011-11-12');
|
10
7
|
*/
|
11
|
-
|
12
|
-
if (
|
8
|
+
export const isDate = createRule(({ message = IS_DATE_RULE_DEFAULT_MESSAGE } = {}) => (value) => {
|
9
|
+
if (isEmptyString(value)) {
|
13
10
|
return undefined;
|
14
11
|
}
|
15
12
|
if (typeof value === 'string') {
|
package/isEmail/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("./isEmail"), exports);
|
1
|
+
export * from './isEmail';
|
package/isEmail/isEmail.js
CHANGED
@@ -1,27 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.isEmail = exports.INVALID_LENGTH_ERROR_MESSAGE = exports.DEFAULT_ERROR_MESSAGE = exports.EMAIL_MAX_LENGTH = void 0;
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
6
3
|
const EMAIL_REGEXP = /^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,}$/;
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
export const EMAIL_MAX_LENGTH = 256;
|
5
|
+
export const DEFAULT_ERROR_MESSAGE = 'Некорректный E-mail';
|
6
|
+
export const INVALID_LENGTH_ERROR_MESSAGE = 'E-mail слишком длинный';
|
10
7
|
/**
|
11
8
|
* @description Проверяет валиден ли email
|
12
9
|
* @example isEmail()('test@example.com');
|
13
10
|
*/
|
14
|
-
|
11
|
+
export const isEmail = createRule(({ message = DEFAULT_ERROR_MESSAGE, invalidLengthMessage = INVALID_LENGTH_ERROR_MESSAGE, } = {}) => (value) => {
|
15
12
|
if (typeof value !== 'string') {
|
16
13
|
return message;
|
17
14
|
}
|
18
|
-
if (
|
15
|
+
if (isEmptyString(value)) {
|
19
16
|
return undefined;
|
20
17
|
}
|
21
18
|
if (!EMAIL_REGEXP.test(value)) {
|
22
19
|
return message;
|
23
20
|
}
|
24
|
-
if (value.length >
|
21
|
+
if (value.length > EMAIL_MAX_LENGTH) {
|
25
22
|
return invalidLengthMessage;
|
26
23
|
}
|
27
24
|
return undefined;
|
package/isINNIP/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("./isINNIP"), exports);
|
1
|
+
export * from './isINNIP';
|
package/isINNIP/isINNIP.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ИП';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ИП';
|
7
4
|
const INNIP_LENGTH = 12;
|
8
5
|
const FIRST_INN_UL_DECODING = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
|
9
6
|
const SECOND_INN_UL_DECODING = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
|
@@ -21,8 +18,8 @@ const calcSecondCheckSumForInnUl = (arrSymbols) => (arrSymbols
|
|
21
18
|
* @description Проверяет валиден ли ИНН ИП
|
22
19
|
* @example isINNIP()('384212952720');
|
23
20
|
*/
|
24
|
-
|
25
|
-
if (
|
21
|
+
export const isINNIP = createRule(({ message = IS_INNIP_DEFAULT_MESSAGE } = {}) => (value) => {
|
22
|
+
if (isEmptyString(value)) {
|
26
23
|
return undefined;
|
27
24
|
}
|
28
25
|
if (typeof value === 'string') {
|
package/isINNUL/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("./isINNUL"), exports);
|
1
|
+
export * from './isINNUL';
|
package/isINNUL/isINNUL.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const createRule_1 = require("../createRule");
|
5
|
-
const utils_1 = require("../utils");
|
6
|
-
exports.IS_INNUL_DEFAULT_MESSAGE = 'Некорректный ИНН ЮЛ';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { isEmptyString } from '../utils';
|
3
|
+
export const IS_INNUL_DEFAULT_MESSAGE = 'Некорректный ИНН ЮЛ';
|
7
4
|
const INNUL_LENGTH = 10;
|
8
5
|
const INN_UL_DECODING = [2, 4, 10, 3, 5, 9, 4, 6, 8];
|
9
6
|
const calcCheckSumForInnUl = (arrSymbols) => (arrSymbols
|
@@ -15,8 +12,8 @@ const calcCheckSumForInnUl = (arrSymbols) => (arrSymbols
|
|
15
12
|
* @description Проверяет валиден ли ИНН ЮЛ
|
16
13
|
* @example isINNUL()('7728168971');
|
17
14
|
*/
|
18
|
-
|
19
|
-
if (
|
15
|
+
export const isINNUL = createRule(({ message = IS_INNUL_DEFAULT_MESSAGE } = {}) => (value) => {
|
16
|
+
if (isEmptyString(value)) {
|
20
17
|
return undefined;
|
21
18
|
}
|
22
19
|
if (typeof value === 'string') {
|
package/isMaxLength/index.js
CHANGED
@@ -1,5 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isMaxLength = void 0;
|
4
|
-
var isMaxLength_1 = require("./isMaxLength");
|
5
|
-
Object.defineProperty(exports, "isMaxLength", { enumerable: true, get: function () { return isMaxLength_1.isMaxLength; } });
|
1
|
+
export { isMaxLength } from './isMaxLength';
|
@@ -1,15 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
exports.isMaxLength = exports.getDefaultMessage = void 0;
|
7
|
-
const lodash_isempty_1 = __importDefault(require("lodash.isempty"));
|
8
|
-
const createRule_1 = require("../createRule");
|
9
|
-
const constants_1 = require("../constants");
|
10
|
-
const utils_1 = require("../utils");
|
11
|
-
const getDefaultMessage = (max) => `Макс. символов: ${max}`;
|
12
|
-
exports.getDefaultMessage = getDefaultMessage;
|
1
|
+
import isEmpty from 'lodash.isempty';
|
2
|
+
import { createRule } from '../createRule';
|
3
|
+
import { INCORRECT_MESSAGE } from '../constants';
|
4
|
+
import { isEmptyString } from '../utils';
|
5
|
+
export const getDefaultMessage = (max) => `Макс. символов: ${max}`;
|
13
6
|
/**
|
14
7
|
* @description Проверяет максимальную длину value
|
15
8
|
* @example isMaxLength({ max: 10 })(1239123);
|
@@ -18,11 +11,11 @@ exports.getDefaultMessage = getDefaultMessage;
|
|
18
11
|
* @param {string} [message.defaultMessage] Сообщение при неудачной валидации
|
19
12
|
* @param {string} [message.incorrectValue] Сообщение при переданном некорректном value
|
20
13
|
*/
|
21
|
-
|
22
|
-
defaultMessage:
|
23
|
-
incorrectValue:
|
14
|
+
export const isMaxLength = createRule(({ max, message = {
|
15
|
+
defaultMessage: getDefaultMessage(max),
|
16
|
+
incorrectValue: INCORRECT_MESSAGE,
|
24
17
|
}, }) => (value) => {
|
25
|
-
if (
|
18
|
+
if (isEmptyString(value)) {
|
26
19
|
return undefined;
|
27
20
|
}
|
28
21
|
if (max < 0) {
|
@@ -34,7 +27,7 @@ exports.isMaxLength = (0, createRule_1.createRule)(({ max, message = {
|
|
34
27
|
if (typeof value !== 'string' || !Array.isArray(value)) {
|
35
28
|
return message.incorrectValue;
|
36
29
|
}
|
37
|
-
if ((
|
30
|
+
if (isEmpty(value)) {
|
38
31
|
return undefined;
|
39
32
|
}
|
40
33
|
return undefined;
|
package/isMaxValue/index.js
CHANGED
@@ -1,5 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isMaxValue = void 0;
|
4
|
-
var isMaxValue_1 = require("./isMaxValue");
|
5
|
-
Object.defineProperty(exports, "isMaxValue", { enumerable: true, get: function () { return isMaxValue_1.isMaxValue; } });
|
1
|
+
export { isMaxValue } from './isMaxValue';
|
package/isMaxValue/isMaxValue.js
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const isMaybeNumber_1 = require("../isMaybeNumber");
|
7
|
-
const utils_1 = require("../utils");
|
8
|
-
const getDefaultMessage = (max) => {
|
1
|
+
import { INCORRECT_MESSAGE } from '../constants';
|
2
|
+
import { createRule } from '../createRule';
|
3
|
+
import { isMaybeNumber } from '../isMaybeNumber';
|
4
|
+
import { isEmptyString } from '../utils';
|
5
|
+
export const getDefaultMessage = (max) => {
|
9
6
|
return `Должно быть меньше чем ${max}`;
|
10
7
|
};
|
11
|
-
exports.getDefaultMessage = getDefaultMessage;
|
12
8
|
/**
|
13
9
|
* @description Проверяет максимальное значение value
|
14
10
|
* @example isMaxValue({ max: 10 })(1239123);
|
@@ -16,14 +12,14 @@ exports.getDefaultMessage = getDefaultMessage;
|
|
16
12
|
* @param {string} [message.defaultMessage] Сообщение при неудачной валидации
|
17
13
|
* @param {string} [message.incorrectValue] Сообщение при переданном некорректном value
|
18
14
|
*/
|
19
|
-
|
15
|
+
export const isMaxValue = createRule(({ max, message = {
|
20
16
|
defaultMessage: `Должно быть меньше чем ${max}`,
|
21
|
-
incorrectValue:
|
17
|
+
incorrectValue: INCORRECT_MESSAGE,
|
22
18
|
}, }) => (value) => {
|
23
|
-
if (
|
19
|
+
if (isEmptyString(value)) {
|
24
20
|
return undefined;
|
25
21
|
}
|
26
|
-
if (typeof value === 'string' && !
|
22
|
+
if (typeof value === 'string' && !isMaybeNumber()(value)) {
|
27
23
|
if (parseFloat(value) <= max) {
|
28
24
|
return undefined;
|
29
25
|
}
|
package/isMaybeNumber/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("./isMaybeNumber"), exports);
|
1
|
+
export * from './isMaybeNumber';
|
@@ -1,21 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const
|
5
|
-
const constants_1 = require("../constants");
|
6
|
-
const utils_1 = require("../utils");
|
7
|
-
exports.IS_MAYBE_NUMBER_RULE_DEFAULT_MESSAGE = 'Не может быть преобразовано в число';
|
1
|
+
import { createRule } from '../createRule';
|
2
|
+
import { CONTAINS_SPACES_REGEX } from '../constants';
|
3
|
+
import { isEmptyString } from '../utils';
|
4
|
+
export const IS_MAYBE_NUMBER_RULE_DEFAULT_MESSAGE = 'Не может быть преобразовано в число';
|
8
5
|
/**
|
9
6
|
* @description Проверяет может ли значение быть преобразованным в число
|
10
7
|
* @example isMaybeNumber()('7728168971');
|
11
8
|
*/
|
12
|
-
|
13
|
-
if (
|
9
|
+
export const isMaybeNumber = createRule(({ message = IS_MAYBE_NUMBER_RULE_DEFAULT_MESSAGE } = {}) => (value) => {
|
10
|
+
if (isEmptyString(value)) {
|
14
11
|
return undefined;
|
15
12
|
}
|
16
13
|
if (typeof value === 'string' &&
|
17
14
|
!isNaN(Number(value)) &&
|
18
|
-
!
|
15
|
+
!CONTAINS_SPACES_REGEX.test(value) &&
|
19
16
|
value !== '') {
|
20
17
|
return undefined;
|
21
18
|
}
|
package/isMinLength/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("./isMinLength"), exports);
|
1
|
+
export * from './isMinLength';
|
@@ -1,15 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
exports.isMinLength = exports.getDefaultMessage = void 0;
|
7
|
-
const lodash_isempty_1 = __importDefault(require("lodash.isempty"));
|
8
|
-
const createRule_1 = require("../createRule");
|
9
|
-
const constants_1 = require("../constants");
|
10
|
-
const utils_1 = require("../utils");
|
11
|
-
const getDefaultMessage = (min) => `Мин. символов: ${min}`;
|
12
|
-
exports.getDefaultMessage = getDefaultMessage;
|
1
|
+
import isEmpty from 'lodash.isempty';
|
2
|
+
import { createRule } from '../createRule';
|
3
|
+
import { INCORRECT_MESSAGE } from '../constants';
|
4
|
+
import { isEmptyString } from '../utils';
|
5
|
+
export const getDefaultMessage = (min) => `Мин. символов: ${min}`;
|
13
6
|
/**
|
14
7
|
* @description Проверяет минимальную длину value
|
15
8
|
* @example isMinLength({ min: 10 })(1239123);
|
@@ -18,11 +11,11 @@ exports.getDefaultMessage = getDefaultMessage;
|
|
18
11
|
* @param {string} [message.defaultMessage] Сообщение при неудачной валидации
|
19
12
|
* @param {string} [message.incorrectValue] Сообщение при переданном некорректном value
|
20
13
|
*/
|
21
|
-
|
14
|
+
export const isMinLength = createRule(({ min, message = {
|
22
15
|
defaultMessage: `Мин. символов: ${min}`,
|
23
|
-
incorrectValue:
|
16
|
+
incorrectValue: INCORRECT_MESSAGE,
|
24
17
|
}, } = { min: 0 }) => (value) => {
|
25
|
-
if (
|
18
|
+
if (isEmptyString(value)) {
|
26
19
|
return undefined;
|
27
20
|
}
|
28
21
|
if (min < 0) {
|
@@ -34,7 +27,7 @@ exports.isMinLength = (0, createRule_1.createRule)(({ min, message = {
|
|
34
27
|
if (typeof value !== 'string' || !Array.isArray(value)) {
|
35
28
|
return message.incorrectValue;
|
36
29
|
}
|
37
|
-
if ((
|
30
|
+
if (isEmpty(value)) {
|
38
31
|
return undefined;
|
39
32
|
}
|
40
33
|
return undefined;
|
package/isMinValue/index.js
CHANGED
@@ -1,5 +1 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isMinValue = void 0;
|
4
|
-
var isMinValue_1 = require("./isMinValue");
|
5
|
-
Object.defineProperty(exports, "isMinValue", { enumerable: true, get: function () { return isMinValue_1.isMinValue; } });
|
1
|
+
export { isMinValue } from './isMinValue';
|
package/isMinValue/isMinValue.js
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const isMaybeNumber_1 = require("../isMaybeNumber");
|
7
|
-
const utils_1 = require("../utils");
|
8
|
-
const getDefaultMessage = (min) => {
|
1
|
+
import { INCORRECT_MESSAGE } from '../constants';
|
2
|
+
import { createRule } from '../createRule';
|
3
|
+
import { isMaybeNumber } from '../isMaybeNumber';
|
4
|
+
import { isEmptyString } from '../utils';
|
5
|
+
export const getDefaultMessage = (min) => {
|
9
6
|
return `Должно быть больше чем ${min}`;
|
10
7
|
};
|
11
|
-
exports.getDefaultMessage = getDefaultMessage;
|
12
8
|
/**
|
13
9
|
* @description Проверяет минимальное значение value
|
14
10
|
* @example isMinValue({ min: 10 })(1239123);
|
@@ -16,14 +12,14 @@ exports.getDefaultMessage = getDefaultMessage;
|
|
16
12
|
* @param {string} [message.defaultMessage] Сообщение при неудачной валидации
|
17
13
|
* @param {string} [message.incorrectValue] Сообщение при переданном некорректном value
|
18
14
|
*/
|
19
|
-
|
15
|
+
export const isMinValue = createRule(({ min, message = {
|
20
16
|
defaultMessage: `Должно быть больше чем ${min}`,
|
21
|
-
incorrectValue:
|
17
|
+
incorrectValue: INCORRECT_MESSAGE,
|
22
18
|
}, } = { min: 0 }) => (value) => {
|
23
|
-
if (
|
19
|
+
if (isEmptyString(value)) {
|
24
20
|
return undefined;
|
25
21
|
}
|
26
|
-
if (typeof value === 'string' && !
|
22
|
+
if (typeof value === 'string' && !isMaybeNumber()(value)) {
|
27
23
|
if (parseFloat(value) >= min) {
|
28
24
|
return undefined;
|
29
25
|
}
|