react-hook-form-rules 1.0.3 → 1.0.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.
@@ -3,6 +3,4 @@
3
3
  * @param value - Массиов со значениями
4
4
  * @example getMaxArrayLengthRule(2, "Максимальное кол-во значений - 2")
5
5
  */
6
- export declare const getMaxArrayLengthRule: (max: number, message: string) => {
7
- validator(_: unknown, value: unknown[]): Promise<void>;
8
- };
6
+ export declare const getMaxArrayLengthRule: (value: unknown[]) => true | "Это поле обязательное.";
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMaxArrayLengthRule = void 0;
4
+ const REQUIRED_MESSAGE_TEXT = "Это поле обязательное.";
4
5
  /**
5
6
  * Валидирует массив, на максимальное кол-во значений
6
7
  * @param value - Массиов со значениями
7
8
  * @example getMaxArrayLengthRule(2, "Максимальное кол-во значений - 2")
8
9
  */
9
- const getMaxArrayLengthRule = (max, message) => ({
10
- validator(_, value) {
11
- if ((value === null || value === void 0 ? void 0 : value.length) > max) {
12
- return Promise.reject(message);
13
- }
14
- return Promise.resolve();
15
- }
16
- });
10
+ const getMaxArrayLengthRule = (value) => {
11
+ return value.length > 0 || REQUIRED_MESSAGE_TEXT;
12
+ };
17
13
  exports.getMaxArrayLengthRule = getMaxArrayLengthRule;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "react-hook-form-rules",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "tsc --declaration"
9
+ "build": "tsc --declaration",
10
+ "publish": "npm run build && npm publish"
10
11
  },
11
12
  "keywords": [],
12
13
  "author": "",