@astral/validations 2.1.3 → 2.1.4

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
@@ -1,8 +1,6 @@
1
1
  export * from './createRule';
2
2
  export * from './yupAdapter';
3
3
  export * from './compose';
4
- export * from './composeAllSettled';
5
- export * from './composeToString';
6
4
  export * from './isRequired';
7
5
  export * from './types';
8
6
  export * from './isINNUL';
package/esm/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  export * from './createRule';
2
2
  export * from './yupAdapter';
3
3
  export * from './compose';
4
- export * from './composeAllSettled';
5
- export * from './composeToString';
6
4
  export * from './isRequired';
7
5
  export * from './types';
8
6
  export * from './isINNUL';
@@ -1,4 +1,4 @@
1
- export declare const IS_INNIP_DEFAULT_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0418\u041D\u041D \u042E\u041B";
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
2
  /**
3
3
  * @description Проверяет валиден ли ИНН ИП
4
4
  * @example isINNIP()('384212952720');
@@ -1,6 +1,6 @@
1
1
  import { createRule } from '../createRule';
2
2
  import { isEmptyString } from '../utils';
3
- export const IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ЮЛ';
3
+ export const IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ИП';
4
4
  const INNIP_LENGTH = 12;
5
5
  const FIRST_INN_UL_DECODING = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
6
6
  const SECOND_INN_UL_DECODING = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
package/esm/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type RuleError = string | string[];
1
+ export type RuleError = string;
2
2
  export type ValidationResult = RuleError | undefined;
3
3
  export type InitializedRule = (value?: unknown) => ValidationResult;
4
4
  export type Rule<Params extends object, RequiredParams extends boolean> = RequiredParams extends true ? (params: Params) => InitializedRule : (params?: Params) => InitializedRule;
package/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export * from './createRule';
2
2
  export * from './yupAdapter';
3
3
  export * from './compose';
4
- export * from './composeAllSettled';
5
- export * from './composeToString';
6
4
  export * from './isRequired';
7
5
  export * from './types';
8
6
  export * from './isINNUL';
package/index.js CHANGED
@@ -17,8 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./createRule"), exports);
18
18
  __exportStar(require("./yupAdapter"), exports);
19
19
  __exportStar(require("./compose"), exports);
20
- __exportStar(require("./composeAllSettled"), exports);
21
- __exportStar(require("./composeToString"), exports);
22
20
  __exportStar(require("./isRequired"), exports);
23
21
  __exportStar(require("./types"), exports);
24
22
  __exportStar(require("./isINNUL"), exports);
@@ -1,4 +1,4 @@
1
- export declare const IS_INNIP_DEFAULT_MESSAGE = "\u041D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u044B\u0439 \u0418\u041D\u041D \u042E\u041B";
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
2
  /**
3
3
  * @description Проверяет валиден ли ИНН ИП
4
4
  * @example isINNIP()('384212952720');
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isINNIP = exports.IS_INNIP_DEFAULT_MESSAGE = void 0;
4
4
  const createRule_1 = require("../createRule");
5
5
  const utils_1 = require("../utils");
6
- exports.IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ЮЛ';
6
+ exports.IS_INNIP_DEFAULT_MESSAGE = 'Некорректный ИНН ИП';
7
7
  const INNIP_LENGTH = 12;
8
8
  const FIRST_INN_UL_DECODING = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
9
9
  const SECOND_INN_UL_DECODING = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/validations",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "browser": "./esm/index.js",
5
5
  "main": "./index.js",
6
6
  "dependencies": {
package/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type RuleError = string | string[];
1
+ export type RuleError = string;
2
2
  export type ValidationResult = RuleError | undefined;
3
3
  export type InitializedRule = (value?: unknown) => ValidationResult;
4
4
  export type Rule<Params extends object, RequiredParams extends boolean> = RequiredParams extends true ? (params: Params) => InitializedRule : (params?: Params) => InitializedRule;
@@ -1,7 +0,0 @@
1
- import { InitializedRule, ValidationResult } from '../types';
2
- /**
3
- * @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил. Выполняет правила слева направо
4
- * @example composeAllSettled(isIncludeDot(), isIncludeComma());
5
- * @example compose(isRequired(), composeAllSettled(isIncludeDot(), isIncludeComma()));
6
- */
7
- export declare const composeAllSettled: (...rules: InitializedRule[]) => (value: unknown) => ValidationResult;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeAllSettled = void 0;
4
- /**
5
- * @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил. Выполняет правила слева направо
6
- * @example composeAllSettled(isIncludeDot(), isIncludeComma());
7
- * @example compose(isRequired(), composeAllSettled(isIncludeDot(), isIncludeComma()));
8
- */
9
- const composeAllSettled = (...rules) => (value) => {
10
- const errors = [];
11
- rules.forEach((rule) => {
12
- const error = rule(value);
13
- if (Array.isArray(error)) {
14
- errors.push(...error);
15
- }
16
- if (typeof error === 'string') {
17
- errors.push(error);
18
- }
19
- });
20
- if (!errors.length) {
21
- return undefined;
22
- }
23
- return errors.length === 1 ? errors[0] : errors;
24
- };
25
- exports.composeAllSettled = composeAllSettled;
@@ -1 +0,0 @@
1
- export * from './composeAllSettled';
@@ -1,17 +0,0 @@
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("./composeAllSettled"), exports);
@@ -1,8 +0,0 @@
1
- import { InitializedRule } from '../types';
2
- /**
3
- * @description Объединяет правила в цепочку и форматирует результат в одну строку. Останаваливается при возникновении ошибки. Работает слева направо
4
- * Подходит в качестве адаптера к react-final-form
5
- * @example composeToString(isIncludeDot(), isIncludeComma());
6
- * @example composeToString(isRequired(), composeToString(isIncludeDot(), isIncludeComma()));
7
- */
8
- export declare const composeToString: (...rules: InitializedRule[]) => (value?: unknown) => string | undefined;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeToString = void 0;
4
- const compose_1 = require("../compose");
5
- /**
6
- * @description Объединяет правила в цепочку и форматирует результат в одну строку. Останаваливается при возникновении ошибки. Работает слева направо
7
- * Подходит в качестве адаптера к react-final-form
8
- * @example composeToString(isIncludeDot(), isIncludeComma());
9
- * @example composeToString(isRequired(), composeToString(isIncludeDot(), isIncludeComma()));
10
- */
11
- const composeToString = (...rules) => (value) => {
12
- const validationResult = (0, compose_1.compose)(...rules)(value);
13
- if (Array.isArray(validationResult)) {
14
- return validationResult[0];
15
- }
16
- return validationResult;
17
- };
18
- exports.composeToString = composeToString;
@@ -1 +0,0 @@
1
- export * from './composeToString';
@@ -1,17 +0,0 @@
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("./composeToString"), exports);
@@ -1,7 +0,0 @@
1
- import { InitializedRule, ValidationResult } from '../types';
2
- /**
3
- * @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил. Выполняет правила слева направо
4
- * @example composeAllSettled(isIncludeDot(), isIncludeComma());
5
- * @example compose(isRequired(), composeAllSettled(isIncludeDot(), isIncludeComma()));
6
- */
7
- export declare const composeAllSettled: (...rules: InitializedRule[]) => (value: unknown) => ValidationResult;
@@ -1,21 +0,0 @@
1
- /**
2
- * @description Объединяет переданные правила в цепочку правил, выполняя все переданные правила, независимо от результата выполнения правил. Выполняет правила слева направо
3
- * @example composeAllSettled(isIncludeDot(), isIncludeComma());
4
- * @example compose(isRequired(), composeAllSettled(isIncludeDot(), isIncludeComma()));
5
- */
6
- export const composeAllSettled = (...rules) => (value) => {
7
- const errors = [];
8
- rules.forEach((rule) => {
9
- const error = rule(value);
10
- if (Array.isArray(error)) {
11
- errors.push(...error);
12
- }
13
- if (typeof error === 'string') {
14
- errors.push(error);
15
- }
16
- });
17
- if (!errors.length) {
18
- return undefined;
19
- }
20
- return errors.length === 1 ? errors[0] : errors;
21
- };
@@ -1 +0,0 @@
1
- export * from './composeAllSettled';
@@ -1 +0,0 @@
1
- export * from './composeAllSettled';
@@ -1,8 +0,0 @@
1
- import { InitializedRule } from '../types';
2
- /**
3
- * @description Объединяет правила в цепочку и форматирует результат в одну строку. Останаваливается при возникновении ошибки. Работает слева направо
4
- * Подходит в качестве адаптера к react-final-form
5
- * @example composeToString(isIncludeDot(), isIncludeComma());
6
- * @example composeToString(isRequired(), composeToString(isIncludeDot(), isIncludeComma()));
7
- */
8
- export declare const composeToString: (...rules: InitializedRule[]) => (value?: unknown) => string | undefined;
@@ -1,14 +0,0 @@
1
- import { compose } from '../compose';
2
- /**
3
- * @description Объединяет правила в цепочку и форматирует результат в одну строку. Останаваливается при возникновении ошибки. Работает слева направо
4
- * Подходит в качестве адаптера к react-final-form
5
- * @example composeToString(isIncludeDot(), isIncludeComma());
6
- * @example composeToString(isRequired(), composeToString(isIncludeDot(), isIncludeComma()));
7
- */
8
- export const composeToString = (...rules) => (value) => {
9
- const validationResult = compose(...rules)(value);
10
- if (Array.isArray(validationResult)) {
11
- return validationResult[0];
12
- }
13
- return validationResult;
14
- };
@@ -1 +0,0 @@
1
- export * from './composeToString';
@@ -1 +0,0 @@
1
- export * from './composeToString';