koatty_validation 1.0.10 → 1.2.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.
@@ -0,0 +1 @@
1
+ window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":2,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":2,"startTime":1645754279274,"success":false,"testResults":[{"leaks":false,"numFailingTests":0,"numPassingTests":2,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1645754280984,"runtime":1640,"slow":false,"start":1645754279344},"skipped":false,"testFilePath":"/Users/richen/Workspace/nodejs/koatty_validation/test/.test.ts","testResults":[{"ancestorTitles":["koatty_validation"],"duration":1,"failureDetails":[],"failureMessages":[],"fullName":"koatty_validation FunctionValidator","invocations":1,"location":null,"numPassingAsserts":0,"status":"passed","title":"FunctionValidator"},{"ancestorTitles":["koatty_validation"],"duration":2,"failureDetails":[],"failureMessages":[],"fullName":"koatty_validation ClassValidator","invocations":1,"location":null,"numPassingAsserts":0,"status":"passed","title":"ClassValidator"}],"failureMessage":null}],"wasInterrupted":false,"config":{"bail":0,"changedFilesWithAncestor":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"coverage","coverageProvider":"babel","coverageReporters":["html","lcov","json","text","clover","text-summary"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"passWithNoTests":true,"projects":[],"reporters":[["default",{}],["/Users/richen/Workspace/nodejs/koatty_validation/node_modules/jest-html-reporters/index.js",{}]],"rootDir":"/Users/richen/Workspace/nodejs/koatty_validation","runTestsByPath":false,"skipFilter":false,"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/Users/richen/Workspace/nodejs/koatty_validation/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true},"endTime":1645754281125,"_reporterOptions":{"publicPath":"/Users/richen/Workspace/nodejs/koatty_validation","filename":"jest_html_reporters.html","expand":false,"pageTitle":"","hideIcon":false,"testCommand":"npx jest","openReport":false,"failureMessageOnly":false,"enableMergeData":false,"dataMergeLevel":1},"attachInfos":{}})
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
1
  {
2
2
  "name": "koatty_validation",
3
- "version": "1.0.10",
3
+ "version": "1.2.0",
4
4
  "description": "Validation Util for Koatty and ThinkORM.",
5
5
  "scripts": {
6
- "build": "del-cli --force dist && tsc",
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup -c",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
7
11
  "eslint": "eslint --ext .ts,.js ./",
8
12
  "prepublishOnly": "npm test && npm run build",
9
- "release": "npm run prepublishOnly && standard-version",
13
+ "prerelease": "npm test && npm run build",
14
+ "release": "standard-version",
15
+ "release:pre": "npm run release -- --prerelease",
16
+ "release:major": "npm run release -- --release-as major",
17
+ "release:minor": "npm run release -- --release-as minor",
10
18
  "pub": "git push --follow-tags origin && npm publish",
11
19
  "test": "npm run eslint && jest --passWithNoTests",
12
20
  "test:cov": "jest --collectCoverage --detectOpenHandles",
13
21
  "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
14
22
  },
15
23
  "main": "./dist/index.js",
24
+ "exports": {
25
+ "require": "./dist/index.js",
26
+ "import": "./dist/index.mjs"
27
+ },
16
28
  "repository": {
17
29
  "type": "git",
18
30
  "url": "git+https://github.com/koatty/koatty_validation.git"
19
31
  },
20
- "keywords": [
21
- "validation",
22
- "koatty",
23
- "thinkKoa"
24
- ],
25
32
  "engines": {
26
33
  "node": ">10.0.0"
27
34
  },
@@ -41,25 +48,27 @@
41
48
  }
42
49
  ],
43
50
  "devDependencies": {
44
- "@babel/core": "^7.x.x",
45
- "@babel/plugin-proposal-decorators": "^7.x.x",
46
- "@babel/preset-env": "^7.x.x",
47
- "@babel/preset-typescript": "^7.x.x",
48
- "@commitlint/cli": "^12.x.x",
49
- "@commitlint/config-conventional": "^15.x.x",
51
+ "@microsoft/api-documenter": "^7.x.x",
52
+ "@microsoft/api-extractor": "^7.x.x",
53
+ "@rollup/plugin-json": "^4.x.x",
50
54
  "@types/jest": "^27.x.x",
51
55
  "@types/koa": "^2.x.x",
52
56
  "@types/node": "^16.x.x",
53
- "@types/validator": "^13.7.0",
57
+ "@types/validator": "^13.x.x",
54
58
  "@typescript-eslint/eslint-plugin": "^5.x.x",
55
59
  "@typescript-eslint/parser": "^5.x.x",
60
+ "commitlint": "^15.x.x",
61
+ "commitlint-config-gitmoji": "^2.x.x",
56
62
  "conventional-changelog-cli": "^2.x.x",
63
+ "copyfiles": "^2.x.x",
57
64
  "del-cli": "^4.x.x",
58
65
  "eslint": "^8.x.x",
59
66
  "eslint-plugin-jest": "^25.x.x",
60
67
  "husky": "^7.x.x",
61
68
  "jest": "^27.x.x",
62
69
  "jest-html-reporters": "^2.x.x",
70
+ "rollup": "^2.x.x",
71
+ "rollup-plugin-typescript2": "^0.x.x",
63
72
  "standard-version": "^9.x.x",
64
73
  "ts-jest": "^27.x.x",
65
74
  "ts-node": "^10.x.x",
@@ -73,9 +82,9 @@
73
82
  "reflect-metadata": "^0.1.13",
74
83
  "tslib": "^2.3.1"
75
84
  },
76
- "husky": {
77
- "hooks": {
78
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
79
- }
85
+ "peerDependencies": {
86
+ "koatty_container": "^1.x.x",
87
+ "koatty_lib": "^1.x.x",
88
+ "koatty_logger": "^1.x.x"
80
89
  }
81
90
  }
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- node_modules
2
- .eslintrc.js
3
- **/package-lock.json
4
- **/yarn.lock
5
- **/*.config.js
6
- dist
7
- coverage
8
- test
9
- demo
package/.eslintrc.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- *
3
- */
4
- module.exports = {
5
- root: true,
6
- parser: '@typescript-eslint/parser',
7
- extends: [
8
- 'plugin:@typescript-eslint/recommended', // 使用@typescript-eslint/eslint-plugin的推荐规则
9
- 'plugin:jest/recommended',
10
- ],
11
- plugins: [
12
- '@typescript-eslint',
13
- 'jest',
14
- ],
15
- parserOptions: {
16
- project: './tsconfig.json',
17
- },
18
- env: {
19
- node: true,
20
- mongo: true,
21
- jest: true,
22
- },
23
- rules: {
24
- "@typescript-eslint/no-explicit-any": "off",
25
- // "@typescript-eslint/no-require-imports": "off",
26
- "@typescript-eslint/no-var-requires": "off",
27
- "@typescript-eslint/member-ordering": "off",
28
- "@typescript-eslint/consistent-type-assertions": "off",
29
- "@typescript-eslint/no-param-reassign": "off",
30
- "@typescript-eslint/no-empty-function": "off",
31
- "@typescript-eslint/no-empty-interface": "off",
32
- "@typescript-eslint/explicit-module-boundary-types": "off",
33
- "@typescript-eslint/ban-types": ["error",
34
- {
35
- "types": {
36
- "Object": false,
37
- "Function": false,
38
- },
39
- "extendDefaults": true
40
- }
41
- ],
42
- },
43
- };
package/babel.config.js DELETED
@@ -1,21 +0,0 @@
1
- /*
2
- * @Description : babel配置
3
- * @usage : 用于jest执行用例
4
- */
5
-
6
- module.exports = {
7
- presets: [
8
- [
9
- '@babel/preset-env',
10
- {
11
- targets: {
12
- node: 'current',
13
- },
14
- },
15
- ],
16
- '@babel/preset-typescript',
17
- ],
18
- plugins: [
19
- ['@babel/plugin-proposal-decorators', { 'legacy': true }]
20
- ],
21
- };
@@ -1,14 +0,0 @@
1
- /*
2
- *
3
- */
4
- module.exports = {
5
- extends: ['@commitlint/config-conventional'],
6
- rules: {
7
- 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
8
- 'type-empty': [2, 'never'],
9
- 'scope-enum': [0], // 不校验scope类型
10
- 'scope-empty': [0], // 不校验scope是否设置
11
- 'subject-case': [0], // 不校验描述的字符格式
12
- 'subject-min-length': [2, 'always', 5], // 描述至少5个字符
13
- },
14
- };
@@ -1,237 +0,0 @@
1
- import { CountryCode } from 'libphonenumber-js';
2
- import { ValidRules } from "./rule";
3
- import { IsIpVersion, ValidationOptions } from "class-validator";
4
- export interface IsEmailOptions {
5
- allow_display_name?: boolean;
6
- require_display_name?: boolean;
7
- allow_utf8_local_part?: boolean;
8
- require_tld?: boolean;
9
- }
10
- export interface IsURLOptions {
11
- protocols?: string[];
12
- require_tld?: boolean;
13
- require_protocol?: boolean;
14
- require_host?: boolean;
15
- require_valid_protocol?: boolean;
16
- allow_underscores?: boolean;
17
- host_whitelist?: (string | RegExp)[];
18
- host_blacklist?: (string | RegExp)[];
19
- allow_trailing_dot?: boolean;
20
- allow_protocol_relative_urls?: boolean;
21
- disallow_auth?: boolean;
22
- }
23
- export declare type HashAlgorithm = "md4" | "md5" | "sha1" | "sha256" | "sha384" | "sha512" | "ripemd128" | "ripemd160" | "tiger128" | "tiger160" | "tiger192" | "crc32" | "crc32b";
24
- /**
25
- * Validation parameter's type and values.
26
- *
27
- * @export
28
- * @param {(ValidRules | ValidRules[] | Function)} rule
29
- * @param {string} [message]
30
- * @returns {ParameterDecorator}
31
- */
32
- export declare function Valid(rule: ValidRules | ValidRules[] | Function, message?: string): ParameterDecorator;
33
- /**
34
- * Validation parameter's type and values from DTO class.
35
- *
36
- * @export
37
- * @returns {MethodDecorator}
38
- */
39
- export declare function Validated(): MethodDecorator;
40
- /**
41
- * Marks property as included in the process of transformation.
42
- *
43
- * @export
44
- * @returns {PropertyDecorator}
45
- */
46
- export declare function Expose(): PropertyDecorator;
47
- /**
48
- * Identifies that the field needs to be defined
49
- *
50
- * @export
51
- * @returns {PropertyDecorator}
52
- */
53
- export declare function IsDefined(): PropertyDecorator;
54
- /**
55
- * Checks if value is a chinese name.
56
- *
57
- * @export
58
- * @param {string} property
59
- * @param {ValidationOptions} [validationOptions]
60
- * @returns {PropertyDecorator}
61
- */
62
- export declare function IsCnName(validationOptions?: ValidationOptions): PropertyDecorator;
63
- /**
64
- * Checks if value is a idCard number(chinese).
65
- *
66
- * @export
67
- * @param {string} property
68
- * @param {ValidationOptions} [validationOptions]
69
- * @returns {PropertyDecorator}
70
- */
71
- export declare function IsIdNumber(validationOptions?: ValidationOptions): PropertyDecorator;
72
- /**
73
- * Checks if value is a zipCode(chinese).
74
- *
75
- * @export
76
- * @param {string} property
77
- * @param {ValidationOptions} [validationOptions]
78
- * @returns {PropertyDecorator}
79
- */
80
- export declare function IsZipCode(validationOptions?: ValidationOptions): PropertyDecorator;
81
- /**
82
- * Checks if value is a mobile phone number(chinese).
83
- *
84
- * @export
85
- * @param {string} property
86
- * @param {ValidationOptions} [validationOptions]
87
- * @returns {PropertyDecorator}
88
- */
89
- export declare function IsMobile(validationOptions?: ValidationOptions): PropertyDecorator;
90
- /**
91
- * Checks if value is a plate number(chinese).
92
- *
93
- * @export
94
- * @param {string} property
95
- * @param {ValidationOptions} [validationOptions]
96
- * @returns {PropertyDecorator}
97
- */
98
- export declare function IsPlateNumber(validationOptions?: ValidationOptions): PropertyDecorator;
99
- /**
100
- * Checks value is not empty, undefined, null, '', NaN, [], {} and any empty string(including spaces, tabs, formfeeds, etc.), returns false.
101
- *
102
- * @export
103
- * @param {ValidationOptions} [validationOptions]
104
- * @returns {PropertyDecorator}
105
- */
106
- export declare function IsNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator;
107
- /**
108
- * Checks if value matches ("===") the comparison.
109
- *
110
- * @export
111
- * @param {*} comparison
112
- * @param {ValidationOptions} [validationOptions]
113
- * @returns {PropertyDecorator}
114
- */
115
- export declare function Equals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator;
116
- /**
117
- * Checks if value does not match ("!==") the comparison.
118
- *
119
- * @export
120
- * @param {*} comparison
121
- * @param {ValidationOptions} [validationOptions]
122
- * @returns {PropertyDecorator}
123
- */
124
- export declare function NotEquals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator;
125
- /**
126
- * Checks if the string contains the seed.
127
- *
128
- * @export
129
- * @param {string} seed
130
- * @param {ValidationOptions} [validationOptions]
131
- * @returns {PropertyDecorator}
132
- */
133
- export declare function Contains(seed: string, validationOptions?: ValidationOptions): PropertyDecorator;
134
- /**
135
- * Checks if given value is in a array of allowed values.
136
- *
137
- * @export
138
- * @param {any[]} possibleValues
139
- * @param {ValidationOptions} [validationOptions]
140
- * @returns {PropertyDecorator}
141
- */
142
- export declare function IsIn(possibleValues: any[], validationOptions?: ValidationOptions): PropertyDecorator;
143
- /**
144
- * Checks if given value not in a array of allowed values.
145
- *
146
- * @export
147
- * @param {any[]} possibleValues
148
- * @param {ValidationOptions} [validationOptions]
149
- * @returns {PropertyDecorator}
150
- */
151
- export declare function IsNotIn(possibleValues: any[], validationOptions?: ValidationOptions): PropertyDecorator;
152
- /**
153
- * Checks if a given value is a real date.
154
- *
155
- * @export
156
- * @param {ValidationOptions} [validationOptions]
157
- * @returns {PropertyDecorator}
158
- */
159
- export declare function IsDate(validationOptions?: ValidationOptions): PropertyDecorator;
160
- /**
161
- * Checks if the first number is greater than or equal to the min value.
162
- *
163
- * @export
164
- * @param {number} min
165
- * @param {ValidationOptions} [validationOptions]
166
- * @returns {PropertyDecorator}
167
- */
168
- export declare function Min(min: number, validationOptions?: ValidationOptions): PropertyDecorator;
169
- /**
170
- * Checks if the first number is less than or equal to the max value.
171
- *
172
- * @export
173
- * @param {number} max
174
- * @param {ValidationOptions} [validationOptions]
175
- * @returns {PropertyDecorator}
176
- */
177
- export declare function Max(max: number, validationOptions?: ValidationOptions): PropertyDecorator;
178
- /**
179
- * Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs.
180
- * If given value is not a string, then it returns false.
181
- *
182
- * @export
183
- * @param {number} min
184
- * @param {number} [max]
185
- * @param {ValidationOptions} [validationOptions]
186
- * @returns {PropertyDecorator}
187
- */
188
- export declare function Length(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator;
189
- /**
190
- * Checks if the string is an email. If given value is not a string, then it returns false.
191
- *
192
- * @export
193
- * @param {IsEmailOptions} [options]
194
- * @param {ValidationOptions} [validationOptions]
195
- * @returns {PropertyDecorator}
196
- */
197
- export declare function IsEmail(options?: IsEmailOptions, validationOptions?: ValidationOptions): PropertyDecorator;
198
- /**
199
- * Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.
200
- *
201
- * @export
202
- * @param {number} [version]
203
- * @param {ValidationOptions} [validationOptions]
204
- * @returns {PropertyDecorator}
205
- */
206
- export declare function IsIP(version?: IsIpVersion, validationOptions?: ValidationOptions): PropertyDecorator;
207
- /**
208
- * Checks if the string is a valid phone number.
209
- *
210
- * @export
211
- * @param {string} {string} region 2 characters uppercase country code (e.g. DE, US, CH).
212
- * If users must enter the intl. prefix (e.g. +41), then you may pass "ZZ" or null as region.
213
- * See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
214
- * {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
215
- * @param {ValidationOptions} [validationOptions]
216
- * @returns {PropertyDecorator}
217
- */
218
- export declare function IsPhoneNumber(region?: CountryCode, validationOptions?: ValidationOptions): PropertyDecorator;
219
- /**
220
- * Checks if the string is an url.
221
- *
222
- * @export
223
- * @param {IsURLOptions} [options]
224
- * @param {ValidationOptions} [validationOptions]
225
- * @returns {PropertyDecorator}
226
- */
227
- export declare function IsUrl(options?: IsURLOptions, validationOptions?: ValidationOptions): PropertyDecorator;
228
- /**
229
- * check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256',
230
- * 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
231
- *
232
- * @export
233
- * @param {HashAlgorithm} algorithm
234
- * @param {ValidationOptions} [validationOptions]
235
- * @returns {PropertyDecorator}
236
- */
237
- export declare function IsHash(algorithm: HashAlgorithm, validationOptions?: ValidationOptions): PropertyDecorator;