Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

koatty_validation

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koatty_validation - npm Package Compare versions

Comparing version
2.0.8
to
2.1.0
+4
.turbo/turbo-clean.log
> koatty_validation@2.0.7 clean /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> rimraf dist temp docs/api
> koatty_validation@2.0.8 lint /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> eslint --ext .ts,.js ./src

Sorry, the diff of this file is not supported yet

+16
-16

> koatty_validation@2.0.8 build /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> koatty_validation@2.1.0 build /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> pnpm run build:js && pnpm run build:dts && pnpm run build:doc && pnpm run build:cp
> koatty_validation@2.0.8 build:js /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> koatty_validation@2.1.0 build:js /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> tsup

@@ -18,10 +18,10 @@

ESM Build start
ESM dist/index.mjs 42.45 KB
ESM dist/index.mjs.map 104.32 KB
ESM ⚡️ Build success in 123ms
CJS dist/index.js 44.91 KB
CJS dist/index.js.map 104.40 KB
CJS ⚡️ Build success in 123ms
CJS dist/index.js 45.90 KB
CJS dist/index.js.map 106.43 KB
CJS ⚡️ Build success in 131ms
ESM dist/index.mjs 43.45 KB
ESM dist/index.mjs.map 106.35 KB
ESM ⚡️ Build success in 131ms
> koatty_validation@2.0.8 build:dts /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> koatty_validation@2.1.0 build:dts /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> bash ../../scripts/build-dts.sh

@@ -37,3 +37,3 @@

✅ All dependencies ready (waited 0ms)
✅ All dependencies ready (waited 1ms)
📝 Running TypeScript compiler...

@@ -92,6 +92,6 @@ ⠙📦 Running API Extractor...

Warning: src/util.ts:254:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
Warning: src/util.ts:323:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
Warning: src/util.ts:324:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
Warning: src/util.ts:325:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
Warning: src/util.ts:325:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
Warning: src/util.ts:348:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
Warning: src/util.ts:349:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
Warning: src/util.ts:350:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
Warning: src/util.ts:350:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"

@@ -101,3 +101,3 @@ API Extractor completed successfully

> koatty_validation@2.0.8 build:doc /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> koatty_validation@2.1.0 build:doc /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> api-documenter markdown --input temp --output docs/api

@@ -129,3 +129,3 @@

> koatty_validation@2.0.8 build:cp /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> koatty_validation@2.1.0 build:cp /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> node ../../scripts/postBuild.js

@@ -132,0 +132,0 @@

> koatty_validation@1.6.3 test /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> npm run eslint && jest --passWithNoTests
> koatty_validation@2.0.6 test /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> pnpm run lint && jest --passWithNoTests
> koatty_validation@1.6.3 eslint
> eslint --ext .ts,.js ./
> koatty_validation@2.0.6 lint /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation
> eslint --ext .ts,.js ./src
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
<transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced
PASS test/error-handler.test.ts
PASS test/util.test.ts
PASS test/performance-cache.test.ts
PASS test/integration.test.ts
PASS test/decorator-factory.test.ts
PASS test/cache-hit-rate.test.ts
PASS test/function-validator.test.ts
PASS test/validfuncs.test.ts
PASS test/validated-decorator.test.ts
PASS test/return-all-errors.test.ts
● Console
console.log
Default behavior error: 手机号格式不正确
at Object.<anonymous> (test/return-all-errors.test.ts:40:15)
console.log
All errors: 手机号格式不正确; 姓名必须是有效的中文姓名; 邮箱格式不正确
at Object.<anonymous> (test/return-all-errors.test.ts:85:15)
console.log
Error details: [
{
"field": "phoneNum",
"value": "123",
"constraint": "IsMobile",
"message": "手机号格式不正确",
"context": {
"IsMobile": "手机号格式不正确"
}
},
{
"field": "userName",
"value": "aaaaaaaaaaa",
"constraint": "IsCnName",
"message": "姓名必须是有效的中文姓名",
"context": {
"IsCnName": "姓名必须是有效的中文姓名"
}
},
{
"field": "email",
"value": "invalid-email",
"constraint": "IsEmail",
"message": "邮箱格式不正确",
"context": {
"IsEmail": "邮箱格式不正确"
}
}
]
at Object.<anonymous> (test/return-all-errors.test.ts:86:15)
console.log
Custom separator error: 手机号格式不正确 | 姓名必须是有效的中文姓名 | 邮箱格式不正确
at Object.<anonymous> (test/return-all-errors.test.ts:111:15)
console.log
Single error: 手机号格式不正确
at Object.<anonymous> (test/return-all-errors.test.ts:136:15)
console.log
Validated DTO: TestDTO {
phoneNum: '13812345678',
userName: '张三',
email: 'test@example.com'
}
at Object.<anonymous> (test/return-all-errors.test.ts:159:13)
console.log
[2026-04-24 11:12:56.551 +08:00] DEBUG MetadataCache initialized with 8 cache types, base capacity: 3000, TTL: 600000ms
at Console.log (../../node_modules/.pnpm/winston@3.19.0/node_modules/winston/lib/winston/transports/console.js:87:23)
console.log
[2026-04-24 11:12:56.557 +08:00] DEBUG Container initialized with metadata cache
at Console.log (../../node_modules/.pnpm/winston@3.19.0/node_modules/winston/lib/winston/transports/console.js:87:23)
PASS test/.test.ts
● Console
console.log
false
at Object.<anonymous> (test/.test.ts:38:21)
console.log
✅ Default behavior: Only first error returned
at Object.<anonymous> (test/.test.ts:88:21)
console.log
✅ All errors returned: 字段1不能为空; 手机号无效; 邮箱无效
at Object.<anonymous> (test/.test.ts:118:21)
console.log
Error details: [
{
"field": "field1",
"value": "",
"constraint": "IsNotEmpty",
"message": "字段1不能为空",
"context": {
"IsNotEmpty": "字段1不能为空"
}
},
{
"field": "phone",
"value": "123",
"constraint": "IsMobile",
"message": "手机号无效",
"context": {
"IsMobile": "手机号无效"
}
},
{
"field": "email",
"value": "invalid-email",
"constraint": "IsEmail",
"message": "邮箱无效",
"context": {
"IsEmail": "邮箱无效"
}
}
]
at Object.<anonymous> (test/.test.ts:119:21)
console.log
✅ Custom separator: 字段1不能为空 | 手机号无效 | 邮箱无效
at Object.<anonymous> (test/.test.ts:142:21)
console.log
✅ Single error handled correctly
at Object.<anonymous> (test/.test.ts:165:21)
console.log
[2026-04-24 11:12:56.635 +08:00] DEBUG MetadataCache initialized with 8 cache types, base capacity: 3000, TTL: 600000ms
at Console.log (../../node_modules/.pnpm/winston@3.19.0/node_modules/winston/lib/winston/transports/console.js:87:23)
console.log
[2026-04-24 11:12:56.635 +08:00] DEBUG Container initialized with metadata cache
at Console.log (../../node_modules/.pnpm/winston@3.19.0/node_modules/winston/lib/winston/transports/console.js:87:23)
PASS test/custom-decorators-example.test.ts
📦 report is created on: /Volumes/ExternalSSD/Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-validation/jest_html_reporters.html
----------------------|---------|----------|---------|---------|----------------------------------------------------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------|---------|----------|---------|---------|----------------------------------------------------------------------------
All files | 82.3 | 78.24 | 73.71 | 81.57 |
decorator-factory.ts | 100 | 71.42 | 100 | 100 | 29,58
decorators.ts | 78.12 | 74.41 | 43.24 | 77.89 | 30,42,55,62,68,74,80,86,99,105,111,129-131,137-139,145-147,153-155,175-176
error-handler.ts | 96.36 | 90.9 | 100 | 95.83 | 177,201
index.ts | 100 | 100 | 0 | 100 |
performance-cache.ts | 80.27 | 82.35 | 86.04 | 80 | 120,152-161,205-208,250,265,419-449
rule.ts | 94.79 | 84.61 | 90 | 94.18 | 75,185-198,327
types.ts | 100 | 100 | 100 | 100 |
util.ts | 73.42 | 74.65 | 61.11 | 72.72 | 34-88,100-116,127-135,153,156,161,220,231-246,262,267,274,333,420,437
----------------------|---------|----------|---------|---------|----------------------------------------------------------------------------
Test Suites: 12 passed, 12 total
Tests: 198 passed, 198 total
Snapshots: 0 total
Time: 4.23 s
Ran all test suites.
# Changelog
## 2.0.8
## 2.1.0
### Minor Changes
- build
- build
### Patch Changes
- Updated dependencies
- koatty_container@2.0.8
- Updated dependencies
- koatty_container@3.0.0
- koatty_lib@1.5.0
- koatty_logger@3.0.0

@@ -14,4 +22,8 @@ ## 2.0.7

- build
- Updated dependencies
- koatty_container@2.0.7
- Updated dependencies
- koatty_container@2.0.9
- koatty_lib@1.4.9
- koatty_logger@2.8.5

@@ -18,0 +30,0 @@ ## 2.0.6

/*!
* @Author: richen
* @Date: 2026-03-08 12:45:03
* @Date: 2026-04-24 16:20:28
* @License: BSD (3-Clause)

@@ -5,0 +5,0 @@ * @Copyright (c) - <richenlin(at)gmail.com>

@@ -31,3 +31,3 @@ 'use strict';

* @Author: richen
* @Date: 2026-03-08 04:45:00
* @Date: 2026-04-24 08:20:25
* @License: BSD (3-Clause)

@@ -549,3 +549,10 @@ * @Copyright (c) - <richenlin(at)gmail.com>

case "boolean":
return !!param;
if (typeof param === "boolean") return param;
if (param === null || param === void 0) return param;
if (typeof param === "string") {
const lower = param.toLowerCase();
if (lower === "false" || lower === "0") return false;
if (lower === "true" || lower === "1") return true;
}
return Boolean(param);
case "Array":

@@ -555,6 +562,19 @@ case "array":

case "tuple":
if (helper__namespace.isArray(param)) {
return param;
if (helper__namespace.isArray(param)) return param;
if (param === null || param === void 0) return param;
if (typeof param === "string") {
try {
const parsed = JSON.parse(param);
return Array.isArray(parsed) ? parsed : [
param
];
} catch {
return [
param
];
}
}
return helper__namespace.toArray(param);
return [
param
];
case "String":

@@ -578,3 +598,14 @@ case "string":

return BigInt(param);
// case "object":
case "Object":
case "object":
if (param === null || param === void 0) return param;
if (typeof param === "object" && !Array.isArray(param)) return param;
if (typeof param === "string") {
try {
return JSON.parse(param);
} catch {
return param;
}
}
return param;
// case "enum":

@@ -581,0 +612,0 @@ default:

@@ -9,3 +9,3 @@ import * as helper from 'koatty_lib';

* @Author: richen
* @Date: 2026-03-08 04:45:00
* @Date: 2026-04-24 08:20:25
* @License: BSD (3-Clause)

@@ -527,3 +527,10 @@ * @Copyright (c) - <richenlin(at)gmail.com>

case "boolean":
return !!param;
if (typeof param === "boolean") return param;
if (param === null || param === void 0) return param;
if (typeof param === "string") {
const lower = param.toLowerCase();
if (lower === "false" || lower === "0") return false;
if (lower === "true" || lower === "1") return true;
}
return Boolean(param);
case "Array":

@@ -533,6 +540,19 @@ case "array":

case "tuple":
if (helper.isArray(param)) {
return param;
if (helper.isArray(param)) return param;
if (param === null || param === void 0) return param;
if (typeof param === "string") {
try {
const parsed = JSON.parse(param);
return Array.isArray(parsed) ? parsed : [
param
];
} catch {
return [
param
];
}
}
return helper.toArray(param);
return [
param
];
case "String":

@@ -556,3 +576,14 @@ case "string":

return BigInt(param);
// case "object":
case "Object":
case "object":
if (param === null || param === void 0) return param;
if (typeof param === "object" && !Array.isArray(param)) return param;
if (typeof param === "string") {
try {
return JSON.parse(param);
} catch {
return param;
}
}
return param;
// case "enum":

@@ -559,0 +590,0 @@ default:

{
"name": "koatty_validation",
"version": "2.0.8",
"version": "2.1.0",
"description": "Validation Util for Koatty and ThinkORM.",

@@ -67,13 +67,13 @@ "scripts": {

"class-validator": "^0.14.3",
"koatty_container": "^2.0.8",
"koatty_lib": "^1.4.8",
"koatty_logger": "^2.8.4",
"koatty_container": "^2.1.0",
"koatty_lib": "^1.5.0",
"koatty_logger": "^2.9.0",
"lru-cache": "^11.2.5"
},
"peerDependencies": {
"koatty_container": "^2.0.8",
"koatty_lib": "^1.4.8",
"koatty_logger": "^2.8.4"
"koatty_container": "^2.1.0",
"koatty_lib": "^1.5.0",
"koatty_logger": "^2.9.0"
},
"types": "./index.d.ts"
}
{
"name": "koatty_validation",
"version": "2.0.8",
"version": "2.1.0",
"description": "Validation Util for Koatty and ThinkORM.",

@@ -57,10 +57,10 @@ "main": "./dist/index.js",

"lru-cache": "^11.2.5",
"koatty_lib": "1.4.8",
"koatty_logger": "2.8.4",
"koatty_container": "2.0.8"
"koatty_container": "2.1.0",
"koatty_logger": "2.9.0",
"koatty_lib": "1.5.0"
},
"peerDependencies": {
"koatty_container": "^2.0.8",
"koatty_lib": "^1.4.8",
"koatty_logger": "^2.8.4"
"koatty_container": "^2.1.0",
"koatty_lib": "^1.5.0",
"koatty_logger": "^2.9.0"
},

@@ -67,0 +67,0 @@ "types": "./dist/index.d.ts",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display