koatty_validation 1.4.0 → 1.6.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.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +49 -18
- package/dist/index.js +1304 -1225
- package/dist/index.mjs +1304 -1226
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/.vscode/launch.json +0 -81
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.6.0](https://github.com/koatty/koatty_validation/compare/v1.5.0...v1.6.0) (2025-10-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* improve validation with instance conversion and caching ([9865b93](https://github.com/koatty/koatty_validation/commit/9865b93e469a7df16fe67e0b85dab3191437b0a8))
|
|
11
|
+
|
|
12
|
+
## [1.5.0](https://github.com/koatty/koatty_validation/compare/v1.4.0...v1.5.0) (2025-10-22)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* comprehensive code optimization and enhancements ([f7ac738](https://github.com/koatty/koatty_validation/commit/f7ac7381a75a12365aee2a83530a12044c5e1d44))
|
|
18
|
+
|
|
5
19
|
## [1.4.0](https://github.com/koatty/koatty_validation/compare/v1.3.2...v1.4.0) (2025-06-10)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2025-
|
|
3
|
+
* @Date: 2025-10-23 01:25:11
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -212,15 +212,32 @@ export declare function Expose(): PropertyDecorator;
|
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
214
|
* Use functions or built-in rules for validation.
|
|
215
|
+
* Throws error if validation fails.
|
|
215
216
|
*
|
|
216
217
|
* @export
|
|
217
|
-
* @param {ValidRules} rule
|
|
218
|
-
* @param {unknown} value
|
|
219
|
-
* @param {(string | ValidOtpions)} [options]
|
|
220
|
-
* @returns {*}
|
|
221
218
|
*/
|
|
222
219
|
export declare const FunctionValidator: {
|
|
223
|
-
|
|
220
|
+
readonly IsNotEmpty: (value: unknown, options?: string | ValidOtpions) => void;
|
|
221
|
+
readonly IsDate: (value: unknown, options?: string | ValidOtpions) => void;
|
|
222
|
+
readonly IsEmail: (value: unknown, options?: string | ValidOtpions) => void;
|
|
223
|
+
readonly IsIP: (value: unknown, options?: string | ValidOtpions) => void;
|
|
224
|
+
readonly IsPhoneNumber: (value: unknown, options?: string | ValidOtpions) => void;
|
|
225
|
+
readonly IsUrl: (value: unknown, options?: string | ValidOtpions) => void;
|
|
226
|
+
readonly IsHash: (value: unknown, options?: string | ValidOtpions) => void;
|
|
227
|
+
readonly IsCnName: (value: unknown, options?: string | ValidOtpions) => void;
|
|
228
|
+
readonly IsIdNumber: (value: unknown, options?: string | ValidOtpions) => void;
|
|
229
|
+
readonly IsZipCode: (value: unknown, options?: string | ValidOtpions) => void;
|
|
230
|
+
readonly IsMobile: (value: unknown, options?: string | ValidOtpions) => void;
|
|
231
|
+
readonly IsPlateNumber: (value: unknown, options?: string | ValidOtpions) => void;
|
|
232
|
+
readonly Equals: (value: unknown, options?: string | ValidOtpions) => void;
|
|
233
|
+
readonly NotEquals: (value: unknown, options?: string | ValidOtpions) => void;
|
|
234
|
+
readonly Contains: (value: unknown, options?: string | ValidOtpions) => void;
|
|
235
|
+
readonly IsIn: (value: unknown, options?: string | ValidOtpions) => void;
|
|
236
|
+
readonly IsNotIn: (value: unknown, options?: string | ValidOtpions) => void;
|
|
237
|
+
readonly Gt: (value: unknown, options?: string | ValidOtpions) => void;
|
|
238
|
+
readonly Lt: (value: unknown, options?: string | ValidOtpions) => void;
|
|
239
|
+
readonly Gte: (value: unknown, options?: string | ValidOtpions) => void;
|
|
240
|
+
readonly Lte: (value: unknown, options?: string | ValidOtpions) => void;
|
|
224
241
|
};
|
|
225
242
|
|
|
226
243
|
/**
|
|
@@ -232,6 +249,10 @@ export declare function getAllCacheStats(): {
|
|
|
232
249
|
max: number;
|
|
233
250
|
calculatedSize: number;
|
|
234
251
|
keyCount: number;
|
|
252
|
+
hits: number;
|
|
253
|
+
misses: number;
|
|
254
|
+
hitRate: number;
|
|
255
|
+
totalRequests: number;
|
|
235
256
|
};
|
|
236
257
|
regex: {
|
|
237
258
|
size: number;
|
|
@@ -388,6 +409,11 @@ export declare const PARAM_CHECK_KEY = "PARAM_CHECK_KEY";
|
|
|
388
409
|
|
|
389
410
|
export declare const PARAM_RULE_KEY = "PARAM_RULE_KEY";
|
|
390
411
|
|
|
412
|
+
/**
|
|
413
|
+
* 参数类型键常量
|
|
414
|
+
*/
|
|
415
|
+
export declare const PARAM_TYPE_KEY = "PARAM_TYPE_KEY";
|
|
416
|
+
|
|
391
417
|
/**
|
|
392
418
|
* paramterTypes
|
|
393
419
|
*
|
|
@@ -539,6 +565,7 @@ declare class ValidateClass {
|
|
|
539
565
|
|
|
540
566
|
/**
|
|
541
567
|
* 方法验证装饰器
|
|
568
|
+
* 自动验证方法参数中的 DTO 对象
|
|
542
569
|
*/
|
|
543
570
|
export declare function Validated(): MethodDecorator;
|
|
544
571
|
|
|
@@ -582,6 +609,10 @@ declare class ValidationCache {
|
|
|
582
609
|
max: number;
|
|
583
610
|
calculatedSize: number;
|
|
584
611
|
keyCount: number;
|
|
612
|
+
hits: number;
|
|
613
|
+
misses: number;
|
|
614
|
+
hitRate: number;
|
|
615
|
+
totalRequests: number;
|
|
585
616
|
};
|
|
586
617
|
/**
|
|
587
618
|
* 设置缓存TTL
|
|
@@ -619,7 +650,7 @@ export declare const ValidFuncs: {
|
|
|
619
650
|
/**
|
|
620
651
|
* Checks if a given value is a real date.
|
|
621
652
|
*/
|
|
622
|
-
IsDate: (value: unknown) =>
|
|
653
|
+
IsDate: (value: unknown) => boolean;
|
|
623
654
|
/**
|
|
624
655
|
* Checks if the string is an email. If given value is not a string, then it returns false.
|
|
625
656
|
*/
|
|
@@ -636,11 +667,11 @@ export declare const ValidFuncs: {
|
|
|
636
667
|
* See [google-libphonenumber, metadata.js:countryCodeToRegionCodeMap on github]
|
|
637
668
|
* {@link https://github.com/ruimarinho/google-libphonenumber/blob/1e46138878cff479aafe2ce62175c6c49cb58720/src/metadata.js#L33}
|
|
638
669
|
*/
|
|
639
|
-
IsPhoneNumber: (value:
|
|
670
|
+
IsPhoneNumber: (value: unknown, region?: CountryCode) => boolean;
|
|
640
671
|
/**
|
|
641
672
|
* Checks if the string is an url. If given value is not a string, then it returns false.
|
|
642
673
|
*/
|
|
643
|
-
IsUrl: (value:
|
|
674
|
+
IsUrl: (value: unknown, options?: IsURLOptions) => boolean;
|
|
644
675
|
/**
|
|
645
676
|
* check if the string is a hash of type algorithm. Algorithm is one of
|
|
646
677
|
* ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']
|
|
@@ -649,23 +680,23 @@ export declare const ValidFuncs: {
|
|
|
649
680
|
/**
|
|
650
681
|
* Checks if value is a chinese name.
|
|
651
682
|
*/
|
|
652
|
-
IsCnName: (value:
|
|
683
|
+
IsCnName: (value: unknown) => boolean;
|
|
653
684
|
/**
|
|
654
685
|
* Checks if value is a idcard number.
|
|
655
686
|
*/
|
|
656
|
-
IsIdNumber: (value:
|
|
687
|
+
IsIdNumber: (value: unknown) => boolean;
|
|
657
688
|
/**
|
|
658
689
|
* Checks if value is a zipCode.
|
|
659
690
|
*/
|
|
660
|
-
IsZipCode: (value:
|
|
691
|
+
IsZipCode: (value: unknown) => boolean;
|
|
661
692
|
/**
|
|
662
693
|
* Checks if value is a mobile phone number.
|
|
663
694
|
*/
|
|
664
|
-
IsMobile: (value:
|
|
695
|
+
IsMobile: (value: unknown) => boolean;
|
|
665
696
|
/**
|
|
666
697
|
* Checks if value is a plateNumber.
|
|
667
698
|
*/
|
|
668
|
-
IsPlateNumber: (value:
|
|
699
|
+
IsPlateNumber: (value: unknown) => boolean;
|
|
669
700
|
/**
|
|
670
701
|
* Checks if value matches ("===") the comparison.
|
|
671
702
|
*/
|
|
@@ -689,19 +720,19 @@ export declare const ValidFuncs: {
|
|
|
689
720
|
/**
|
|
690
721
|
* Checks if the first number is greater than or equal to the second.
|
|
691
722
|
*/
|
|
692
|
-
Gt: (
|
|
723
|
+
Gt: (value: unknown, min: number) => boolean;
|
|
693
724
|
/**
|
|
694
725
|
* Checks if the first number is less than or equal to the second.
|
|
695
726
|
*/
|
|
696
|
-
Lt: (
|
|
727
|
+
Lt: (value: unknown, max: number) => boolean;
|
|
697
728
|
/**
|
|
698
729
|
* Checks if the first number is greater than or equal to the second.
|
|
699
730
|
*/
|
|
700
|
-
Gte: (
|
|
731
|
+
Gte: (value: unknown, min: number) => boolean;
|
|
701
732
|
/**
|
|
702
733
|
* Checks if the first number is less than or equal to the second.
|
|
703
734
|
*/
|
|
704
|
-
Lte: (
|
|
735
|
+
Lte: (value: unknown, max: number) => boolean;
|
|
705
736
|
};
|
|
706
737
|
|
|
707
738
|
/**
|