@xfe-repo/bff-validation 1.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # `@xfe-repo/bff-validation`
2
+
3
+ bff validation 验证库
@@ -0,0 +1,201 @@
1
+ import {
2
+ ValidateException,
3
+ __name
4
+ } from "./chunk-GF5IOLXS.mjs";
5
+
6
+ // src/decorator/IsBoolean.decorator.ts
7
+ import { applyDecorators } from "@nestjs/common";
8
+ import { IsBoolean } from "class-validator";
9
+
10
+ // src/decorator/utils.ts
11
+ import { ApiProperty } from "@xfe-repo/bff-core";
12
+ import { Expose } from "class-transformer";
13
+ import { IsNotEmpty } from "class-validator";
14
+
15
+ // src/decorator/IsConditon.decorator.ts
16
+ import { ValidateIf } from "class-validator";
17
+ function IsCondition(condition, options) {
18
+ const { context, message } = options;
19
+ return ValidateIf((obj, value) => {
20
+ const isRequired = condition?.(obj) ?? false;
21
+ const isNotEmpty = value !== null && value !== void 0 && value !== "";
22
+ if (!isNotEmpty && isRequired) {
23
+ const fullMessage = `${context?.description} ${message}`;
24
+ throw new ValidateException(fullMessage);
25
+ }
26
+ return isNotEmpty;
27
+ }, options);
28
+ }
29
+ __name(IsCondition, "IsCondition");
30
+
31
+ // src/decorator/utils.ts
32
+ function transformOptions(options) {
33
+ const { description, extraDesc = "", ...restOptions } = options;
34
+ const context = {
35
+ description
36
+ };
37
+ return {
38
+ ...restOptions,
39
+ description: `${description} ${extraDesc}`,
40
+ context
41
+ };
42
+ }
43
+ __name(transformOptions, "transformOptions");
44
+ function transformRequiredOptions(options) {
45
+ const { context, ...apiOptions } = transformOptions(options);
46
+ const _decorators = [
47
+ ApiProperty(apiOptions),
48
+ Expose(),
49
+ IsNotEmpty({
50
+ context,
51
+ message: "\u4E0D\u80FD\u4E3A\u7A7A"
52
+ })
53
+ ];
54
+ return {
55
+ _decorators,
56
+ context,
57
+ ...apiOptions
58
+ };
59
+ }
60
+ __name(transformRequiredOptions, "transformRequiredOptions");
61
+ function transformOptionalOptions(options) {
62
+ const { context, name, condition, ...apiOptions } = transformOptions(options);
63
+ const _decorators = [
64
+ ApiProperty(apiOptions),
65
+ Expose({
66
+ name
67
+ }),
68
+ IsCondition(condition, {
69
+ context,
70
+ message: "\u4E0D\u80FD\u4E3A\u7A7A"
71
+ })
72
+ ];
73
+ return {
74
+ _decorators,
75
+ context,
76
+ ...apiOptions
77
+ };
78
+ }
79
+ __name(transformOptionalOptions, "transformOptionalOptions");
80
+
81
+ // src/decorator/IsBoolean.decorator.ts
82
+ function IsBooleanRequired(options) {
83
+ const requiredOptions = transformRequiredOptions(options);
84
+ const decorators = transformDecorator(requiredOptions);
85
+ return applyDecorators(...decorators);
86
+ }
87
+ __name(IsBooleanRequired, "IsBooleanRequired");
88
+ function IsBooleanOptional(options) {
89
+ const optionalOptions = transformOptionalOptions(options);
90
+ const decorators = transformDecorator(optionalOptions);
91
+ return applyDecorators(...decorators);
92
+ }
93
+ __name(IsBooleanOptional, "IsBooleanOptional");
94
+ function transformDecorator(options) {
95
+ const { _decorators, context } = options;
96
+ const decorators = [
97
+ ..._decorators,
98
+ /** 禁用隐式类型转换 */
99
+ IsBoolean({
100
+ context,
101
+ message: "\u5FC5\u987B\u4E3A\u5E03\u5C14\u7C7B\u578B"
102
+ })
103
+ ];
104
+ return decorators;
105
+ }
106
+ __name(transformDecorator, "transformDecorator");
107
+
108
+ // src/decorator/IsInt.decorator.ts
109
+ import { applyDecorators as applyDecorators2 } from "@nestjs/common";
110
+ import { Type } from "class-transformer";
111
+ import { IsInt, Max, Min } from "class-validator";
112
+ function IsIntRequired(options) {
113
+ const requiredOptions = transformRequiredOptions(options);
114
+ const decorators = transformDecorator2(requiredOptions);
115
+ return applyDecorators2(...decorators);
116
+ }
117
+ __name(IsIntRequired, "IsIntRequired");
118
+ function IsIntOptional(options) {
119
+ const optionalOptions = transformOptionalOptions(options);
120
+ const decorators = transformDecorator2(optionalOptions);
121
+ return applyDecorators2(...decorators);
122
+ }
123
+ __name(IsIntOptional, "IsIntOptional");
124
+ function transformDecorator2(options) {
125
+ const { _decorators, context, min, max } = options;
126
+ const decorators = [
127
+ ..._decorators,
128
+ /** 隐式类型转换 */
129
+ Type(() => Number),
130
+ IsInt({
131
+ context,
132
+ message: "\u5FC5\u987B\u4E3A\u6574\u6570\u7C7B\u578B"
133
+ })
134
+ ];
135
+ if (min) {
136
+ decorators.push(Min(min, {
137
+ context,
138
+ message: `\u4E0D\u80FD\u5C0F\u4E8E ${min}`
139
+ }));
140
+ }
141
+ if (max) {
142
+ decorators.push(Max(max, {
143
+ context,
144
+ message: `\u4E0D\u80FD\u5927\u4E8E ${max}`
145
+ }));
146
+ }
147
+ return decorators;
148
+ }
149
+ __name(transformDecorator2, "transformDecorator");
150
+
151
+ // src/decorator/IsString.decorator.ts
152
+ import { applyDecorators as applyDecorators3 } from "@nestjs/common";
153
+ import { IsString, MaxLength, MinLength } from "class-validator";
154
+ function IsStringRequired(options) {
155
+ const requiredOptions = transformRequiredOptions(options);
156
+ const decorators = transformDecorator3(requiredOptions);
157
+ return applyDecorators3(...decorators);
158
+ }
159
+ __name(IsStringRequired, "IsStringRequired");
160
+ function IsStringOptional(options) {
161
+ const optionalOptions = transformOptionalOptions(options);
162
+ const decorators = transformDecorator3(optionalOptions);
163
+ return applyDecorators3(...decorators);
164
+ }
165
+ __name(IsStringOptional, "IsStringOptional");
166
+ function transformDecorator3(options) {
167
+ const { _decorators, context, minLength, maxLength } = options;
168
+ const decorators = [
169
+ ..._decorators,
170
+ // string类型 默认不进行隐式类型转换
171
+ IsString({
172
+ context,
173
+ message: "\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u7C7B\u578B"
174
+ })
175
+ ];
176
+ if (minLength) {
177
+ decorators.push(MinLength(minLength, {
178
+ context,
179
+ message: `\u4E0D\u80FD\u5C0F\u4E8E ${minLength} \u4E2A\u5B57\u7B26`
180
+ }));
181
+ }
182
+ if (maxLength) {
183
+ decorators.push(MaxLength(maxLength, {
184
+ context,
185
+ message: `\u4E0D\u80FD\u5927\u4E8E ${maxLength} \u4E2A\u5B57\u7B26`
186
+ }));
187
+ }
188
+ return decorators;
189
+ }
190
+ __name(transformDecorator3, "transformDecorator");
191
+
192
+ export {
193
+ transformRequiredOptions,
194
+ transformOptionalOptions,
195
+ IsBooleanRequired,
196
+ IsBooleanOptional,
197
+ IsIntRequired,
198
+ IsIntOptional,
199
+ IsStringRequired,
200
+ IsStringOptional
201
+ };
@@ -0,0 +1,96 @@
1
+ import {
2
+ ValidateException,
3
+ __name
4
+ } from "./chunk-GF5IOLXS.mjs";
5
+
6
+ // src/validation.pipe.ts
7
+ import { Injectable, ValidationPipe as ValidationPipeOrigin } from "@nestjs/common";
8
+ function _ts_decorate(decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ }
14
+ __name(_ts_decorate, "_ts_decorate");
15
+ function _ts_metadata(k, v) {
16
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
+ }
18
+ __name(_ts_metadata, "_ts_metadata");
19
+ var createValidationPipe = /* @__PURE__ */ __name((options) => {
20
+ return new ValidationPipe(options);
21
+ }, "createValidationPipe");
22
+ var _ValidationPipe = class _ValidationPipe extends ValidationPipeOrigin {
23
+ constructor(options) {
24
+ const excuteWhen = options?.validateCustomDecorators ? "out" : "in";
25
+ const defaultOptions = {
26
+ /** 自动将请求数据转换为 DTO 类实例 */
27
+ transform: true,
28
+ /** 只允许 DTO 中定义的属性, 过滤掉 DTO 中未定义的属性 */
29
+ whitelist: true,
30
+ /** 禁止使用 DTO 中未定义的属性, 如果请求包含未定义的属性,则抛出错误, 暂时关闭 */
31
+ forbidNonWhitelisted: false,
32
+ /**
33
+ * 遇到第一个验证错误就停止验证
34
+ * 这可以提高性能,尤其是在处理大型对象时,但可能会导致某些错误被忽略
35
+ * 如果需要获取所有验证错误,可以将其设置为 false
36
+ */
37
+ stopAtFirstError: true,
38
+ transformOptions: {
39
+ /** 建议在大型 NestJS 项目中,关闭隐式转换,可以确保类型转换的显式性和可控性 */
40
+ enableImplicitConversion: false,
41
+ /** 忽略值为 undefined 的字段 */
42
+ exposeUnsetFields: false
43
+ },
44
+ /** 自定义验证错误格式,返回结构化的错误响应 */
45
+ exceptionFactory: /* @__PURE__ */ __name((errors) => {
46
+ const errorList = getValidationErrors(errors);
47
+ const error = errorList[0];
48
+ const property = error.context?.description || error.property;
49
+ const suffix = excuteWhen === "in" ? "" : "!";
50
+ return new ValidateException(`${property} ${error?.message}${suffix}`, {
51
+ cause: {
52
+ error,
53
+ errors
54
+ }
55
+ });
56
+ }, "exceptionFactory")
57
+ };
58
+ options = {
59
+ ...defaultOptions,
60
+ ...options
61
+ };
62
+ super(options);
63
+ }
64
+ };
65
+ __name(_ValidationPipe, "ValidationPipe");
66
+ var ValidationPipe = _ValidationPipe;
67
+ ValidationPipe = _ts_decorate([
68
+ Injectable(),
69
+ _ts_metadata("design:type", Function),
70
+ _ts_metadata("design:paramtypes", [
71
+ typeof ValidationPipeOptions === "undefined" ? Object : ValidationPipeOptions
72
+ ])
73
+ ], ValidationPipe);
74
+ function getValidationErrors(errors, parentProperty = "") {
75
+ const formattedErrors = [];
76
+ for (const error of errors) {
77
+ const propertyPath = parentProperty ? `${parentProperty}.${error.property}` : error.property;
78
+ if (error.constraints) {
79
+ formattedErrors.push({
80
+ property: propertyPath,
81
+ context: Object.values(error.contexts || {})?.[0],
82
+ message: Object.values(error.constraints)?.[0]
83
+ });
84
+ }
85
+ if (error.children?.length) {
86
+ formattedErrors.push(...getValidationErrors(error.children, propertyPath));
87
+ }
88
+ }
89
+ return formattedErrors;
90
+ }
91
+ __name(getValidationErrors, "getValidationErrors");
92
+
93
+ export {
94
+ createValidationPipe,
95
+ ValidationPipe
96
+ };
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+
6
+ // src/validation.exception.ts
7
+ import { BadRequestException } from "@nestjs/common";
8
+ var ERROR_TYPE_ENUM = /* @__PURE__ */ function(ERROR_TYPE_ENUM2) {
9
+ ERROR_TYPE_ENUM2["VALIDATE_ERROR"] = "VALIDATE_ERROR";
10
+ ERROR_TYPE_ENUM2["API_RESPONSE_ERROR"] = "API_RESPONSE_ERROR";
11
+ return ERROR_TYPE_ENUM2;
12
+ }({});
13
+ var _ValidateException = class _ValidateException extends BadRequestException {
14
+ constructor(message, options = {}) {
15
+ super(message, options);
16
+ __publicField(this, "name", "VALIDATE_ERROR");
17
+ }
18
+ };
19
+ __name(_ValidateException, "ValidateException");
20
+ var ValidateException = _ValidateException;
21
+ var _ApiResponseException = class _ApiResponseException extends Error {
22
+ constructor(object) {
23
+ const { code, msg, data } = object;
24
+ super(msg);
25
+ __publicField(this, "code");
26
+ __publicField(this, "msg");
27
+ __publicField(this, "data");
28
+ __publicField(this, "name", "API_RESPONSE_ERROR");
29
+ this.code = code;
30
+ this.msg = msg;
31
+ this.data = data;
32
+ }
33
+ };
34
+ __name(_ApiResponseException, "ApiResponseException");
35
+ var ApiResponseException = _ApiResponseException;
36
+
37
+ export {
38
+ __name,
39
+ __publicField,
40
+ ERROR_TYPE_ENUM,
41
+ ValidateException,
42
+ ApiResponseException
43
+ };
@@ -0,0 +1,78 @@
1
+ import { Type } from '@nestjs/common';
2
+ import { ApiPropertyOptions } from '@xfe-repo/bff-core';
3
+ import { ValidationOptions, IsNumberOptions } from 'class-validator';
4
+ export { ApiResponseException, ApiResponseType, ERROR_TYPE_ENUM, ValidateException } from './validation.exception.mjs';
5
+ export { ValidationPipe, createValidationPipe } from './validation.pipe.mjs';
6
+
7
+ type PropertyDecoratorTyped<T, TK extends keyof T> = (target: T, propertyKey: TK) => void;
8
+ type PropertyDecoratorRequired<T, TK extends keyof T, PT> = undefined extends T[TK] ? T[TK] : PT extends T[TK] ? PropertyDecoratorTyped<T, TK> : T[TK];
9
+ type PropertyDecoratorOptional<T, TK extends keyof T, PT> = undefined extends T[TK] ? (PT extends T[TK] ? PropertyDecoratorTyped<T, TK> : T[TK]) : T[TK];
10
+ interface PickApiPropertyOptions<PT> {
11
+ description: string;
12
+ example?: PT;
13
+ deprecated?: boolean;
14
+ oneOf?: ApiPropertyOptions['oneOf'];
15
+ }
16
+ interface ExtraValidatorOptions {
17
+ extraDesc?: string;
18
+ }
19
+ type ValidatorOptions<PT> = PickApiPropertyOptions<PT> & ExtraValidatorOptions;
20
+ interface IsOptionalOptions<CT> {
21
+ name?: string;
22
+ condition?: (ctx: CT) => boolean;
23
+ }
24
+
25
+ interface ExtraOptions$2 {
26
+ type: [Type] | [Function];
27
+ }
28
+ type IsArrayRequiredOptions<T, TK extends keyof T> = ValidatorOptions<T[TK]> & ExtraOptions$2;
29
+ type IsArrayOptionalOptions<T, TK extends keyof T> = IsArrayRequiredOptions<T, TK> & IsOptionalOptions<T>;
30
+ declare function IsArrayRequired<T, TK extends keyof T>(options: IsArrayRequiredOptions<T, TK>): PropertyDecoratorRequired<T, TK, any[]>;
31
+ declare function IsArrayOptional<T, TK extends keyof T>(options: IsArrayOptionalOptions<T, TK>): PropertyDecoratorOptional<T, TK, any[]>;
32
+
33
+ type IsBooleanRequiredOptions = ValidatorOptions<boolean>;
34
+ type IsBooleanOptionalOptions<T> = IsBooleanRequiredOptions & IsOptionalOptions<T>;
35
+ declare function IsBooleanRequired<T, TK extends keyof T>(options: IsBooleanRequiredOptions): PropertyDecoratorRequired<T, TK, boolean>;
36
+ declare function IsBooleanOptional<T, TK extends keyof T>(options: IsBooleanOptionalOptions<T>): PropertyDecoratorOptional<T, TK, boolean>;
37
+
38
+ interface ExtraOptions$1 {
39
+ enum: ApiPropertyOptions['enum'];
40
+ }
41
+ type IsEnumRequiredOptions = ValidatorOptions<ApiPropertyOptions['enum']> & ExtraOptions$1;
42
+ type IsEnumOptionalOptions<T> = IsEnumRequiredOptions & IsOptionalOptions<T>;
43
+ declare function IsEnumRequired<T, TK extends keyof T>(options: IsEnumRequiredOptions): PropertyDecoratorTyped<T, TK>;
44
+ declare function IsEnumOptional<T, TK extends keyof T>(options: IsEnumOptionalOptions<T>): PropertyDecoratorTyped<T, TK>;
45
+
46
+ interface IsNumberExtraOptions {
47
+ min?: number;
48
+ max?: number;
49
+ }
50
+ type IsNumberRequiredOptions = ValidatorOptions<number> & IsNumberExtraOptions;
51
+ type IsNumberOptionalOptions<T> = IsNumberRequiredOptions & IsOptionalOptions<T>;
52
+ declare function IsNumberRequired<T, TK extends keyof T>(options: IsNumberRequiredOptions): PropertyDecoratorRequired<T, TK, number>;
53
+ declare function IsNumberOptional<T, TK extends keyof T>(options: IsNumberOptionalOptions<T>): PropertyDecoratorOptional<T, TK, number>;
54
+ declare function IsNumber(validationOptions: ValidationOptions, options?: IsNumberOptions): PropertyDecorator;
55
+
56
+ declare function IsIntRequired<T, TK extends keyof T>(options: IsNumberRequiredOptions): PropertyDecoratorRequired<T, TK, number>;
57
+ declare function IsIntOptional<T, TK extends keyof T>(options: IsNumberOptionalOptions<T>): PropertyDecoratorOptional<T, TK, number>;
58
+
59
+ type IsMobileRequiredOptions = ValidatorOptions<string>;
60
+ type IsMobileOptionalOptions<T> = IsMobileRequiredOptions & IsOptionalOptions<T>;
61
+ declare function IsMobileRequired<T, TK extends keyof T>(options: IsMobileRequiredOptions): PropertyDecoratorRequired<T, TK, string>;
62
+ declare function IsMobileOptional<T, TK extends keyof T>(options: IsMobileOptionalOptions<T>): PropertyDecoratorOptional<T, TK, string>;
63
+
64
+ type IsObjectRequiredOptions<T, TK extends keyof T> = ValidatorOptions<T[TK]>;
65
+ type IsObjectOptionalOptions<T, TK extends keyof T> = IsObjectRequiredOptions<T, TK> & IsOptionalOptions<T>;
66
+ declare function IsObjectRequired<T, TK extends keyof T>(options: IsObjectRequiredOptions<T, TK>): PropertyDecoratorRequired<T, TK, T[TK]>;
67
+ declare function IsObjectOptional<T, TK extends keyof T>(options: IsObjectOptionalOptions<T, TK>): PropertyDecoratorOptional<T, TK, T[TK]>;
68
+
69
+ interface ExtraOptions {
70
+ minLength?: number;
71
+ maxLength?: number;
72
+ }
73
+ type IsStringRequiredOptions = ValidatorOptions<string> & ExtraOptions;
74
+ type IsStringOptionalOptions<T> = IsStringRequiredOptions & IsOptionalOptions<T>;
75
+ declare function IsStringRequired<T, TK extends keyof T>(options: IsStringRequiredOptions): PropertyDecoratorRequired<T, TK, string>;
76
+ declare function IsStringOptional<T, TK extends keyof T>(options: IsStringOptionalOptions<T>): PropertyDecoratorOptional<T, TK, string>;
77
+
78
+ export { IsArrayOptional, type IsArrayOptionalOptions, IsArrayRequired, type IsArrayRequiredOptions, IsBooleanOptional, type IsBooleanOptionalOptions, IsBooleanRequired, type IsBooleanRequiredOptions, IsEnumOptional, type IsEnumOptionalOptions, IsEnumRequired, type IsEnumRequiredOptions, IsIntOptional, IsIntRequired, IsMobileOptional, type IsMobileOptionalOptions, IsMobileRequired, type IsMobileRequiredOptions, IsNumber, type IsNumberExtraOptions, IsNumberOptional, type IsNumberOptionalOptions, IsNumberRequired, type IsNumberRequiredOptions, IsObjectOptional, type IsObjectOptionalOptions, IsObjectRequired, type IsObjectRequiredOptions, IsStringOptional, type IsStringOptionalOptions, IsStringRequired, type IsStringRequiredOptions };
@@ -0,0 +1,78 @@
1
+ import { Type } from '@nestjs/common';
2
+ import { ApiPropertyOptions } from '@xfe-repo/bff-core';
3
+ import { ValidationOptions, IsNumberOptions } from 'class-validator';
4
+ export { ApiResponseException, ApiResponseType, ERROR_TYPE_ENUM, ValidateException } from './validation.exception.js';
5
+ export { ValidationPipe, createValidationPipe } from './validation.pipe.js';
6
+
7
+ type PropertyDecoratorTyped<T, TK extends keyof T> = (target: T, propertyKey: TK) => void;
8
+ type PropertyDecoratorRequired<T, TK extends keyof T, PT> = undefined extends T[TK] ? T[TK] : PT extends T[TK] ? PropertyDecoratorTyped<T, TK> : T[TK];
9
+ type PropertyDecoratorOptional<T, TK extends keyof T, PT> = undefined extends T[TK] ? (PT extends T[TK] ? PropertyDecoratorTyped<T, TK> : T[TK]) : T[TK];
10
+ interface PickApiPropertyOptions<PT> {
11
+ description: string;
12
+ example?: PT;
13
+ deprecated?: boolean;
14
+ oneOf?: ApiPropertyOptions['oneOf'];
15
+ }
16
+ interface ExtraValidatorOptions {
17
+ extraDesc?: string;
18
+ }
19
+ type ValidatorOptions<PT> = PickApiPropertyOptions<PT> & ExtraValidatorOptions;
20
+ interface IsOptionalOptions<CT> {
21
+ name?: string;
22
+ condition?: (ctx: CT) => boolean;
23
+ }
24
+
25
+ interface ExtraOptions$2 {
26
+ type: [Type] | [Function];
27
+ }
28
+ type IsArrayRequiredOptions<T, TK extends keyof T> = ValidatorOptions<T[TK]> & ExtraOptions$2;
29
+ type IsArrayOptionalOptions<T, TK extends keyof T> = IsArrayRequiredOptions<T, TK> & IsOptionalOptions<T>;
30
+ declare function IsArrayRequired<T, TK extends keyof T>(options: IsArrayRequiredOptions<T, TK>): PropertyDecoratorRequired<T, TK, any[]>;
31
+ declare function IsArrayOptional<T, TK extends keyof T>(options: IsArrayOptionalOptions<T, TK>): PropertyDecoratorOptional<T, TK, any[]>;
32
+
33
+ type IsBooleanRequiredOptions = ValidatorOptions<boolean>;
34
+ type IsBooleanOptionalOptions<T> = IsBooleanRequiredOptions & IsOptionalOptions<T>;
35
+ declare function IsBooleanRequired<T, TK extends keyof T>(options: IsBooleanRequiredOptions): PropertyDecoratorRequired<T, TK, boolean>;
36
+ declare function IsBooleanOptional<T, TK extends keyof T>(options: IsBooleanOptionalOptions<T>): PropertyDecoratorOptional<T, TK, boolean>;
37
+
38
+ interface ExtraOptions$1 {
39
+ enum: ApiPropertyOptions['enum'];
40
+ }
41
+ type IsEnumRequiredOptions = ValidatorOptions<ApiPropertyOptions['enum']> & ExtraOptions$1;
42
+ type IsEnumOptionalOptions<T> = IsEnumRequiredOptions & IsOptionalOptions<T>;
43
+ declare function IsEnumRequired<T, TK extends keyof T>(options: IsEnumRequiredOptions): PropertyDecoratorTyped<T, TK>;
44
+ declare function IsEnumOptional<T, TK extends keyof T>(options: IsEnumOptionalOptions<T>): PropertyDecoratorTyped<T, TK>;
45
+
46
+ interface IsNumberExtraOptions {
47
+ min?: number;
48
+ max?: number;
49
+ }
50
+ type IsNumberRequiredOptions = ValidatorOptions<number> & IsNumberExtraOptions;
51
+ type IsNumberOptionalOptions<T> = IsNumberRequiredOptions & IsOptionalOptions<T>;
52
+ declare function IsNumberRequired<T, TK extends keyof T>(options: IsNumberRequiredOptions): PropertyDecoratorRequired<T, TK, number>;
53
+ declare function IsNumberOptional<T, TK extends keyof T>(options: IsNumberOptionalOptions<T>): PropertyDecoratorOptional<T, TK, number>;
54
+ declare function IsNumber(validationOptions: ValidationOptions, options?: IsNumberOptions): PropertyDecorator;
55
+
56
+ declare function IsIntRequired<T, TK extends keyof T>(options: IsNumberRequiredOptions): PropertyDecoratorRequired<T, TK, number>;
57
+ declare function IsIntOptional<T, TK extends keyof T>(options: IsNumberOptionalOptions<T>): PropertyDecoratorOptional<T, TK, number>;
58
+
59
+ type IsMobileRequiredOptions = ValidatorOptions<string>;
60
+ type IsMobileOptionalOptions<T> = IsMobileRequiredOptions & IsOptionalOptions<T>;
61
+ declare function IsMobileRequired<T, TK extends keyof T>(options: IsMobileRequiredOptions): PropertyDecoratorRequired<T, TK, string>;
62
+ declare function IsMobileOptional<T, TK extends keyof T>(options: IsMobileOptionalOptions<T>): PropertyDecoratorOptional<T, TK, string>;
63
+
64
+ type IsObjectRequiredOptions<T, TK extends keyof T> = ValidatorOptions<T[TK]>;
65
+ type IsObjectOptionalOptions<T, TK extends keyof T> = IsObjectRequiredOptions<T, TK> & IsOptionalOptions<T>;
66
+ declare function IsObjectRequired<T, TK extends keyof T>(options: IsObjectRequiredOptions<T, TK>): PropertyDecoratorRequired<T, TK, T[TK]>;
67
+ declare function IsObjectOptional<T, TK extends keyof T>(options: IsObjectOptionalOptions<T, TK>): PropertyDecoratorOptional<T, TK, T[TK]>;
68
+
69
+ interface ExtraOptions {
70
+ minLength?: number;
71
+ maxLength?: number;
72
+ }
73
+ type IsStringRequiredOptions = ValidatorOptions<string> & ExtraOptions;
74
+ type IsStringOptionalOptions<T> = IsStringRequiredOptions & IsOptionalOptions<T>;
75
+ declare function IsStringRequired<T, TK extends keyof T>(options: IsStringRequiredOptions): PropertyDecoratorRequired<T, TK, string>;
76
+ declare function IsStringOptional<T, TK extends keyof T>(options: IsStringOptionalOptions<T>): PropertyDecoratorOptional<T, TK, string>;
77
+
78
+ export { IsArrayOptional, type IsArrayOptionalOptions, IsArrayRequired, type IsArrayRequiredOptions, IsBooleanOptional, type IsBooleanOptionalOptions, IsBooleanRequired, type IsBooleanRequiredOptions, IsEnumOptional, type IsEnumOptionalOptions, IsEnumRequired, type IsEnumRequiredOptions, IsIntOptional, IsIntRequired, IsMobileOptional, type IsMobileOptionalOptions, IsMobileRequired, type IsMobileRequiredOptions, IsNumber, type IsNumberExtraOptions, IsNumberOptional, type IsNumberOptionalOptions, IsNumberRequired, type IsNumberRequiredOptions, IsObjectOptional, type IsObjectOptionalOptions, IsObjectRequired, type IsObjectRequiredOptions, IsStringOptional, type IsStringOptionalOptions, IsStringRequired, type IsStringRequiredOptions };