@tsed/schema 7.79.4 → 7.80.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/lib/browser/schema.umd.min.js.map +1 -1
- package/lib/cjs/components/default/inlineEnumsMapper.js +2 -2
- package/lib/cjs/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/cjs/components/default/nullableMapper.js +4 -4
- package/lib/cjs/components/default/nullableMapper.js.map +1 -1
- package/lib/cjs/components/default/requiredMapper.js +4 -4
- package/lib/cjs/components/default/requiredMapper.js.map +1 -1
- package/lib/cjs/components/open-spec/nullableMapper.js +4 -4
- package/lib/cjs/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +1 -24
- package/lib/cjs/utils/generateSpec.js.map +1 -1
- package/lib/esm/components/default/inlineEnumsMapper.js.map +1 -1
- package/lib/esm/components/default/nullableMapper.js.map +1 -1
- package/lib/esm/components/default/requiredMapper.js.map +1 -1
- package/lib/esm/components/open-spec/nullableMapper.js.map +1 -1
- package/lib/esm/utils/getJsonSchema.js +1 -1
- package/lib/types/components/default/inlineEnumsMapper.d.ts +2 -2
- package/lib/types/components/default/nullableMapper.d.ts +1 -1
- package/lib/types/components/default/requiredMapper.d.ts +2 -2
- package/lib/types/components/open-spec/nullableMapper.d.ts +1 -1
- package/lib/types-esm/components/async-api/channelsMapper.d.ts +2 -0
- package/lib/types-esm/components/async-api/generate.d.ts +1 -0
- package/lib/types-esm/components/async-api/messageMapper.d.ts +6 -0
- package/lib/types-esm/components/async-api/payloadMapper.d.ts +4 -0
- package/lib/types-esm/components/async-api/responseMapper.d.ts +6 -0
- package/lib/types-esm/components/default/anyMapper.d.ts +2 -0
- package/lib/types-esm/components/default/classMapper.d.ts +3 -0
- package/lib/types-esm/components/default/genericsMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inheritedClassMapper.d.ts +5 -0
- package/lib/types-esm/components/default/inlineEnumsMapper.d.ts +3 -0
- package/lib/types-esm/components/default/itemMapper.d.ts +2 -0
- package/lib/types-esm/components/default/lazyRefMapper.d.ts +3 -0
- package/lib/types-esm/components/default/mapMapper.d.ts +9 -0
- package/lib/types-esm/components/default/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/default/objectMapper.d.ts +8 -0
- package/lib/types-esm/components/default/ofMapper.d.ts +3 -0
- package/lib/types-esm/components/default/propertiesMapper.d.ts +3 -0
- package/lib/types-esm/components/default/requiredMapper.d.ts +3 -0
- package/lib/types-esm/components/default/schemaMapper.d.ts +3 -0
- package/lib/types-esm/components/index.d.ts +33 -0
- package/lib/types-esm/components/open-spec/generate.d.ts +1 -0
- package/lib/types-esm/components/open-spec/nullableMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInFilesMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationInParameterMapper.d.ts +10 -0
- package/lib/types-esm/components/open-spec/operationInParametersMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationInQueryMapper.d.ts +2 -0
- package/lib/types-esm/components/open-spec/operationMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationMediaMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationRequestBodyMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/operationResponseMapper.d.ts +3 -0
- package/lib/types-esm/components/open-spec/pathsMapper.d.ts +2 -0
- package/lib/types-esm/constants/OperationVerbs.d.ts +20 -0
- package/lib/types-esm/constants/httpStatusMessages.d.ts +11 -0
- package/lib/types-esm/constants/jsonSchemaProperties.d.ts +7 -0
- package/lib/types-esm/decorators/class/children.d.ts +11 -0
- package/lib/types-esm/decorators/class/discriminatorValue.d.ts +42 -0
- package/lib/types-esm/decorators/collections/collectionContains.d.ts +21 -0
- package/lib/types-esm/decorators/collections/collectionOf.d.ts +101 -0
- package/lib/types-esm/decorators/collections/maxItems.d.ts +48 -0
- package/lib/types-esm/decorators/collections/maxProperties.d.ts +71 -0
- package/lib/types-esm/decorators/collections/minItems.d.ts +52 -0
- package/lib/types-esm/decorators/collections/minProperties.d.ts +70 -0
- package/lib/types-esm/decorators/collections/uniqueItems.d.ts +51 -0
- package/lib/types-esm/decorators/common/additionalProperties.d.ts +11 -0
- package/lib/types-esm/decorators/common/allOf.d.ts +13 -0
- package/lib/types-esm/decorators/common/allow.d.ts +28 -0
- package/lib/types-esm/decorators/common/any.d.ts +38 -0
- package/lib/types-esm/decorators/common/anyOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/const.d.ts +61 -0
- package/lib/types-esm/decorators/common/customKey.d.ts +26 -0
- package/lib/types-esm/decorators/common/default.d.ts +41 -0
- package/lib/types-esm/decorators/common/defaultMsg.d.ts +32 -0
- package/lib/types-esm/decorators/common/description.d.ts +53 -0
- package/lib/types-esm/decorators/common/discriminatorKey.d.ts +1 -0
- package/lib/types-esm/decorators/common/enum.d.ts +101 -0
- package/lib/types-esm/decorators/common/errorMsg.d.ts +6 -0
- package/lib/types-esm/decorators/common/example.d.ts +11 -0
- package/lib/types-esm/decorators/common/examples.d.ts +12 -0
- package/lib/types-esm/decorators/common/exclusiveMaximum.d.ts +70 -0
- package/lib/types-esm/decorators/common/exclusiveMinimum.d.ts +70 -0
- package/lib/types-esm/decorators/common/format.d.ts +466 -0
- package/lib/types-esm/decorators/common/forwardGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/groups.d.ts +12 -0
- package/lib/types-esm/decorators/common/hidden.d.ts +32 -0
- package/lib/types-esm/decorators/common/ignore.d.ts +59 -0
- package/lib/types-esm/decorators/common/integer.d.ts +61 -0
- package/lib/types-esm/decorators/common/jsonEntityFn.d.ts +21 -0
- package/lib/types-esm/decorators/common/maxLength.d.ts +77 -0
- package/lib/types-esm/decorators/common/maximum.d.ts +139 -0
- package/lib/types-esm/decorators/common/minLength.d.ts +78 -0
- package/lib/types-esm/decorators/common/minimum.d.ts +137 -0
- package/lib/types-esm/decorators/common/multipleOf.d.ts +69 -0
- package/lib/types-esm/decorators/common/name.d.ts +32 -0
- package/lib/types-esm/decorators/common/nullable.d.ts +25 -0
- package/lib/types-esm/decorators/common/oneOf.d.ts +17 -0
- package/lib/types-esm/decorators/common/optional.d.ts +10 -0
- package/lib/types-esm/decorators/common/pattern.d.ts +94 -0
- package/lib/types-esm/decorators/common/property.d.ts +11 -0
- package/lib/types-esm/decorators/common/readOnly.d.ts +11 -0
- package/lib/types-esm/decorators/common/recordOf.d.ts +46 -0
- package/lib/types-esm/decorators/common/required.d.ts +44 -0
- package/lib/types-esm/decorators/common/requiredGroups.d.ts +10 -0
- package/lib/types-esm/decorators/common/schema.d.ts +53 -0
- package/lib/types-esm/decorators/common/title.d.ts +39 -0
- package/lib/types-esm/decorators/common/typeError.d.ts +8 -0
- package/lib/types-esm/decorators/common/writeOnly.d.ts +11 -0
- package/lib/types-esm/decorators/config/jsonEntityComponent.d.ts +10 -0
- package/lib/types-esm/decorators/generics/genericOf.d.ts +76 -0
- package/lib/types-esm/decorators/generics/generics.d.ts +14 -0
- package/lib/types-esm/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types-esm/decorators/operations/consumes.d.ts +19 -0
- package/lib/types-esm/decorators/operations/contentType.d.ts +20 -0
- package/lib/types-esm/decorators/operations/deprecated.d.ts +23 -0
- package/lib/types-esm/decorators/operations/header.d.ts +49 -0
- package/lib/types-esm/decorators/operations/in.d.ts +64 -0
- package/lib/types-esm/decorators/operations/inFile.d.ts +25 -0
- package/lib/types-esm/decorators/operations/location.d.ts +22 -0
- package/lib/types-esm/decorators/operations/operation.d.ts +60 -0
- package/lib/types-esm/decorators/operations/operationId.d.ts +10 -0
- package/lib/types-esm/decorators/operations/operationPath.d.ts +21 -0
- package/lib/types-esm/decorators/operations/partial.d.ts +10 -0
- package/lib/types-esm/decorators/operations/path.d.ts +15 -0
- package/lib/types-esm/decorators/operations/produces.d.ts +26 -0
- package/lib/types-esm/decorators/operations/publish.d.ts +1 -0
- package/lib/types-esm/decorators/operations/redirect.d.ts +52 -0
- package/lib/types-esm/decorators/operations/returns.d.ts +267 -0
- package/lib/types-esm/decorators/operations/route.d.ts +133 -0
- package/lib/types-esm/decorators/operations/security.d.ts +23 -0
- package/lib/types-esm/decorators/operations/status.d.ts +127 -0
- package/lib/types-esm/decorators/operations/subscribe.d.ts +1 -0
- package/lib/types-esm/decorators/operations/summary.d.ts +20 -0
- package/lib/types-esm/decorators/operations/tags.d.ts +23 -0
- package/lib/types-esm/decorators/operations/view.d.ts +23 -0
- package/lib/types-esm/domain/DecoratorContext.d.ts +28 -0
- package/lib/types-esm/domain/JsonAliasMap.d.ts +12 -0
- package/lib/types-esm/domain/JsonClassStore.d.ts +12 -0
- package/lib/types-esm/domain/JsonDiscriminator.d.ts +18 -0
- package/lib/types-esm/domain/JsonEntityStore.d.ts +110 -0
- package/lib/types-esm/domain/JsonFormatTypes.d.ts +17 -0
- package/lib/types-esm/domain/JsonLazyRef.d.ts +9 -0
- package/lib/types-esm/domain/JsonMap.d.ts +9 -0
- package/lib/types-esm/domain/JsonMedia.d.ts +11 -0
- package/lib/types-esm/domain/JsonMethodStore.d.ts +92 -0
- package/lib/types-esm/domain/JsonOperation.d.ts +51 -0
- package/lib/types-esm/domain/JsonOperationPathsMap.d.ts +7 -0
- package/lib/types-esm/domain/JsonOperationRoute.d.ts +25 -0
- package/lib/types-esm/domain/JsonParameter.d.ts +22 -0
- package/lib/types-esm/domain/JsonParameterStore.d.ts +52 -0
- package/lib/types-esm/domain/JsonParameterTypes.d.ts +16 -0
- package/lib/types-esm/domain/JsonPropertyStore.d.ts +32 -0
- package/lib/types-esm/domain/JsonRequestBody.d.ts +12 -0
- package/lib/types-esm/domain/JsonResponse.d.ts +18 -0
- package/lib/types-esm/domain/JsonSchema.d.ts +340 -0
- package/lib/types-esm/domain/SpecTypes.d.ts +6 -0
- package/lib/types-esm/hooks/alterIgnore.d.ts +10 -0
- package/lib/types-esm/hooks/alterOneOf.d.ts +3 -0
- package/lib/types-esm/hooks/alterRequiredGroups.d.ts +6 -0
- package/lib/types-esm/index.d.ts +182 -0
- package/lib/types-esm/interfaces/IgnoreCallback.d.ts +4 -0
- package/lib/types-esm/interfaces/JsonHookContext.d.ts +17 -0
- package/lib/types-esm/interfaces/JsonOpenSpec.d.ts +9 -0
- package/lib/types-esm/interfaces/JsonSchemaOptions.d.ts +30 -0
- package/lib/types-esm/registries/JsonSchemaMapperContainer.d.ts +21 -0
- package/lib/types-esm/registries/enumRegistries.d.ts +2 -0
- package/lib/types-esm/utils/buildPath.d.ts +6 -0
- package/lib/types-esm/utils/concatParameters.d.ts +4 -0
- package/lib/types-esm/utils/concatPath.d.ts +1 -0
- package/lib/types-esm/utils/defineStatusModel.d.ts +3 -0
- package/lib/types-esm/utils/from.d.ts +190 -0
- package/lib/types-esm/utils/generateSpec.d.ts +16 -0
- package/lib/types-esm/utils/generics.d.ts +50 -0
- package/lib/types-esm/utils/getComputedType.d.ts +5 -0
- package/lib/types-esm/utils/getInheritedStores.d.ts +8 -0
- package/lib/types-esm/utils/getJsonEntityStore.d.ts +15 -0
- package/lib/types-esm/utils/getJsonPathParameters.d.ts +7 -0
- package/lib/types-esm/utils/getJsonSchema.d.ts +4 -0
- package/lib/types-esm/utils/getJsonType.d.ts +5 -0
- package/lib/types-esm/utils/getOperationsRoutes.d.ts +10 -0
- package/lib/types-esm/utils/getOperationsStores.d.ts +6 -0
- package/lib/types-esm/utils/getPropertiesStores.d.ts +20 -0
- package/lib/types-esm/utils/getSpec.d.ts +34 -0
- package/lib/types-esm/utils/getSpecType.d.ts +12 -0
- package/lib/types-esm/utils/isSuccessStatus.d.ts +2 -0
- package/lib/types-esm/utils/mapHeaders.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types-esm/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types-esm/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types-esm/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types-esm/utils/mapOperationOptions.d.ts +5 -0
- package/lib/types-esm/utils/matchGroups.d.ts +4 -0
- package/lib/types-esm/utils/mergeSpec.d.ts +23 -0
- package/lib/types-esm/utils/operationIdFormatter.d.ts +6 -0
- package/lib/types-esm/utils/ref.d.ts +14 -0
- package/lib/types-esm/utils/removeHiddenOperation.d.ts +2 -0
- package/lib/types-esm/utils/serializeEnumValues.d.ts +5 -0
- package/lib/types-esm/utils/somethingOf.d.ts +1 -0
- package/lib/types-esm/utils/toJsonMapCollection.d.ts +7 -0
- package/lib/types-esm/utils/toJsonRegex.d.ts +5 -0
- package/lib/types-esm/utils/transformToOS2.d.ts +25 -0
- package/lib/types-esm/utils/withErrorMsg.d.ts +6 -0
- package/package.json +21 -17
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -21
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -36
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
|
|
3
|
+
*
|
|
4
|
+
* The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).
|
|
5
|
+
*
|
|
6
|
+
* ::: warning
|
|
7
|
+
* The value of maxLength MUST be a non-negative integer.
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* ::: tip
|
|
11
|
+
* Omitting this keyword has the same behavior as a value of 0.
|
|
12
|
+
* :::
|
|
13
|
+
*
|
|
14
|
+
* ::: warning
|
|
15
|
+
* For v6 user, use @@MaxLength@@ from @tsed/schema instead of @tsed/common.
|
|
16
|
+
* :::
|
|
17
|
+
*
|
|
18
|
+
* ## Example
|
|
19
|
+
* ### With primitive type
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* class Model {
|
|
23
|
+
* @MaxLength(10)
|
|
24
|
+
* property: number;
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Will produce:
|
|
29
|
+
*
|
|
30
|
+
* ```json
|
|
31
|
+
* {
|
|
32
|
+
* "type": "object",
|
|
33
|
+
* "properties": {
|
|
34
|
+
* "property": {
|
|
35
|
+
* "type": "string",
|
|
36
|
+
* "maxLength": 10
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ### With array type
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* class Model {
|
|
46
|
+
* @MaxLength(10)
|
|
47
|
+
* @CollectionOf(String)
|
|
48
|
+
* property: string[];
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Will produce:
|
|
53
|
+
*
|
|
54
|
+
* ```json
|
|
55
|
+
* {
|
|
56
|
+
* "type": "object",
|
|
57
|
+
* "properties": {
|
|
58
|
+
* "property": {
|
|
59
|
+
* "type": "array",
|
|
60
|
+
* "items": {
|
|
61
|
+
* "type": "string",
|
|
62
|
+
* "maxLength": 10
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {number} maxLength The maximum length allowed
|
|
70
|
+
* @decorator
|
|
71
|
+
* @validation
|
|
72
|
+
* @swagger
|
|
73
|
+
* @schema
|
|
74
|
+
* @input
|
|
75
|
+
* @ajv-errors
|
|
76
|
+
*/
|
|
77
|
+
export declare const MaxLength: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(maxLength: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
3
|
+
*
|
|
4
|
+
* If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.
|
|
5
|
+
*
|
|
6
|
+
* ::: warning
|
|
7
|
+
* For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.
|
|
8
|
+
* :::
|
|
9
|
+
*
|
|
10
|
+
* ## Example
|
|
11
|
+
* ### With primitive type
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* class Model {
|
|
15
|
+
* @Maximum(10)
|
|
16
|
+
* property: number;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Will produce:
|
|
21
|
+
*
|
|
22
|
+
* ```json
|
|
23
|
+
* {
|
|
24
|
+
* "type": "object",
|
|
25
|
+
* "properties": {
|
|
26
|
+
* "property": {
|
|
27
|
+
* "type": "number",
|
|
28
|
+
* "maximum": 10
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ### With array type
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* class Model {
|
|
38
|
+
* @Maximum(10)
|
|
39
|
+
* @CollectionOf(Number)
|
|
40
|
+
* property: number[];
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Will produce:
|
|
45
|
+
*
|
|
46
|
+
* ```json
|
|
47
|
+
* {
|
|
48
|
+
* "type": "object",
|
|
49
|
+
* "properties": {
|
|
50
|
+
* "property": {
|
|
51
|
+
* "type": "array",
|
|
52
|
+
* "items": {
|
|
53
|
+
* "type": "number",
|
|
54
|
+
* "maximum": 10
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param {number} maximum The maximum value allowed
|
|
62
|
+
* @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.
|
|
63
|
+
* @decorator
|
|
64
|
+
* @validation
|
|
65
|
+
* @swagger
|
|
66
|
+
* @schema
|
|
67
|
+
* @input
|
|
68
|
+
* @ajv-errors
|
|
69
|
+
*/
|
|
70
|
+
export declare const Maximum: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(maximum: number, exclusive?: boolean) => (...args: any[]) => any>;
|
|
71
|
+
/**
|
|
72
|
+
* The value of `maximum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
73
|
+
*
|
|
74
|
+
* If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to `maximum`.
|
|
75
|
+
*
|
|
76
|
+
* ::: warning
|
|
77
|
+
* For v6 user, use @@Maximum@@ from @tsed/schema instead of @tsed/common.
|
|
78
|
+
* :::
|
|
79
|
+
*
|
|
80
|
+
* ## Example
|
|
81
|
+
* ### With primitive type
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* class Model {
|
|
85
|
+
* @Max(10)
|
|
86
|
+
* property: number;
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* Will produce:
|
|
91
|
+
*
|
|
92
|
+
* ```json
|
|
93
|
+
* {
|
|
94
|
+
* "type": "object",
|
|
95
|
+
* "properties": {
|
|
96
|
+
* "property": {
|
|
97
|
+
* "type": "number",
|
|
98
|
+
* "maximum": 10
|
|
99
|
+
* }
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* ### With array type
|
|
105
|
+
*
|
|
106
|
+
* ```typescript
|
|
107
|
+
* class Model {
|
|
108
|
+
* @Max(10)
|
|
109
|
+
* @CollectionOf(Number)
|
|
110
|
+
* property: number[];
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* Will produce:
|
|
115
|
+
*
|
|
116
|
+
* ```json
|
|
117
|
+
* {
|
|
118
|
+
* "type": "object",
|
|
119
|
+
* "properties": {
|
|
120
|
+
* "property": {
|
|
121
|
+
* "type": "array",
|
|
122
|
+
* "items": {
|
|
123
|
+
* "type": "number",
|
|
124
|
+
* "maximum": 10
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param {number} maximum The maximum value allowed
|
|
132
|
+
* @param {boolean} exclusive Same effect as ExclusiveMaximum decorator.
|
|
133
|
+
* @decorator
|
|
134
|
+
* @validation
|
|
135
|
+
* @swagger
|
|
136
|
+
* @schema
|
|
137
|
+
* @input
|
|
138
|
+
*/
|
|
139
|
+
export declare const Max: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(maximum: number, exclusive?: boolean) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
|
|
4
|
+
*
|
|
5
|
+
* The length of a string instance is defined as the number of its characters as defined by [RFC 7159](http://json-schema.org/latest/json-schema-validation.html#RFC7159).
|
|
6
|
+
*
|
|
7
|
+
* ::: warning
|
|
8
|
+
* The value of minLength MUST be a non-negative integer.
|
|
9
|
+
* :::
|
|
10
|
+
*
|
|
11
|
+
* ::: tip
|
|
12
|
+
* Omitting this keyword has the same behavior as a value of 0.
|
|
13
|
+
* :::
|
|
14
|
+
*
|
|
15
|
+
* ::: warning
|
|
16
|
+
* For v6 user, use @@MinLength@@ from @tsed/schema instead of @tsed/common.
|
|
17
|
+
* :::
|
|
18
|
+
*
|
|
19
|
+
* ## Example
|
|
20
|
+
* ### With primitive type
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* class Model {
|
|
24
|
+
* @MinLength(10)
|
|
25
|
+
* property: number;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Will produce:
|
|
30
|
+
*
|
|
31
|
+
* ```json
|
|
32
|
+
* {
|
|
33
|
+
* "type": "object",
|
|
34
|
+
* "properties": {
|
|
35
|
+
* "property": {
|
|
36
|
+
* "type": "string",
|
|
37
|
+
* "maxLength": 10
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* ### With array type
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* class Model {
|
|
47
|
+
* @MinLength(10)
|
|
48
|
+
* @CollectionOf(String)
|
|
49
|
+
* property: string[];
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* Will produce:
|
|
54
|
+
*
|
|
55
|
+
* ```json
|
|
56
|
+
* {
|
|
57
|
+
* "type": "object",
|
|
58
|
+
* "properties": {
|
|
59
|
+
* "property": {
|
|
60
|
+
* "type": "array",
|
|
61
|
+
* "items": {
|
|
62
|
+
* "type": "string",
|
|
63
|
+
* "minLength": 10
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param {number} minLength
|
|
71
|
+
* @decorator
|
|
72
|
+
* @validation
|
|
73
|
+
* @swagger
|
|
74
|
+
* @schema
|
|
75
|
+
* @input
|
|
76
|
+
* @ajv-errors
|
|
77
|
+
*/
|
|
78
|
+
export declare const MinLength: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minLength: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
3
|
+
*
|
|
4
|
+
* If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.
|
|
5
|
+
*
|
|
6
|
+
* ::: warning
|
|
7
|
+
* This decorator will be removed in v7.
|
|
8
|
+
* For v6 user, use @@Minimum@@ from @tsed/schema instead of @tsed/common.
|
|
9
|
+
* :::
|
|
10
|
+
*
|
|
11
|
+
* ## Example
|
|
12
|
+
* ### With primitive type
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class Model {
|
|
16
|
+
* @Minimum(10)
|
|
17
|
+
* property: number;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Will produce:
|
|
22
|
+
*
|
|
23
|
+
* ```json
|
|
24
|
+
* {
|
|
25
|
+
* "type": "object",
|
|
26
|
+
* "properties": {
|
|
27
|
+
* "property": {
|
|
28
|
+
* "type": "number",
|
|
29
|
+
* "minimum": 10
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* ### With array type
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* class Model {
|
|
39
|
+
* @Minimum(10)
|
|
40
|
+
* @CollectionOf(Number)
|
|
41
|
+
* property: number[];
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Will produce:
|
|
46
|
+
*
|
|
47
|
+
* ```json
|
|
48
|
+
* {
|
|
49
|
+
* "type": "object",
|
|
50
|
+
* "properties": {
|
|
51
|
+
* "property": {
|
|
52
|
+
* "type": "array",
|
|
53
|
+
* "items": {
|
|
54
|
+
* "type": "number",
|
|
55
|
+
* "minimum": 10
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param {number} minimum The minimum value allowed
|
|
63
|
+
* @param {boolean} exclusive
|
|
64
|
+
* @decorator
|
|
65
|
+
* @validation
|
|
66
|
+
* @swagger
|
|
67
|
+
* @schema
|
|
68
|
+
* @input
|
|
69
|
+
* @ajv-errors
|
|
70
|
+
*/
|
|
71
|
+
export declare const Minimum: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minimum: number, exclusive?: boolean) => (...args: any[]) => any>;
|
|
72
|
+
/**
|
|
73
|
+
* The value of `minimum` MUST be a number, representing an inclusive upper limit for a numeric instance.
|
|
74
|
+
*
|
|
75
|
+
* If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to `minimum`.
|
|
76
|
+
*
|
|
77
|
+
* ## Example
|
|
78
|
+
* ### With primitive type
|
|
79
|
+
*
|
|
80
|
+
* ```typescript
|
|
81
|
+
* class Model {
|
|
82
|
+
* @Min(10)
|
|
83
|
+
* property: number;
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* Will produce:
|
|
88
|
+
*
|
|
89
|
+
* ```json
|
|
90
|
+
* {
|
|
91
|
+
* "type": "object",
|
|
92
|
+
* "properties": {
|
|
93
|
+
* "property": {
|
|
94
|
+
* "type": "number",
|
|
95
|
+
* "minimum": 10
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* ### With array type
|
|
102
|
+
*
|
|
103
|
+
* ```typescript
|
|
104
|
+
* class Model {
|
|
105
|
+
* @Min(10)
|
|
106
|
+
* @CollectionOf(Number)
|
|
107
|
+
* property: number[];
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* Will produce:
|
|
112
|
+
*
|
|
113
|
+
* ```json
|
|
114
|
+
* {
|
|
115
|
+
* "type": "object",
|
|
116
|
+
* "properties": {
|
|
117
|
+
* "property": {
|
|
118
|
+
* "type": "array",
|
|
119
|
+
* "items": {
|
|
120
|
+
* "type": "number",
|
|
121
|
+
* "minimum": 10
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @alias Minimum
|
|
129
|
+
* @param minimum The minimum value allowed
|
|
130
|
+
* @param exclusive
|
|
131
|
+
* @decorator
|
|
132
|
+
* @validation
|
|
133
|
+
* @swagger
|
|
134
|
+
* @schema
|
|
135
|
+
* @input
|
|
136
|
+
*/
|
|
137
|
+
export declare const Min: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(minimum: number, exclusive?: boolean) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A numeric instance is valid only if division by this keyword's value results in an integer.
|
|
3
|
+
*
|
|
4
|
+
* ::: warning
|
|
5
|
+
* The value of `multipleOf` MUST be a number, strictly greater than 0.
|
|
6
|
+
* :::
|
|
7
|
+
*
|
|
8
|
+
* ::: warning
|
|
9
|
+
* For v6 user, use @@MultipleOf@@ from @tsed/schema instead of @tsed/common.
|
|
10
|
+
* :::
|
|
11
|
+
*
|
|
12
|
+
* ## Example
|
|
13
|
+
* ### With primitive type
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* class Model {
|
|
17
|
+
* @MultipleOf(2)
|
|
18
|
+
* property: Number;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ```json
|
|
23
|
+
* {
|
|
24
|
+
* "type": "object",
|
|
25
|
+
* "properties": {
|
|
26
|
+
* "property": {
|
|
27
|
+
* "type": "number",
|
|
28
|
+
* "multipleOf": 2
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ### With array type
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* class Model {
|
|
38
|
+
* @CollectionOf(number)
|
|
39
|
+
* @MultipleOf(2)
|
|
40
|
+
* property: number[];
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Will produce:
|
|
45
|
+
*
|
|
46
|
+
* ```json
|
|
47
|
+
* {
|
|
48
|
+
* "type": "object",
|
|
49
|
+
* "properties": {
|
|
50
|
+
* "property": {
|
|
51
|
+
* "type": "array",
|
|
52
|
+
* "items": {
|
|
53
|
+
* "type": "number",
|
|
54
|
+
* "multipleOf": 2
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param {number} multipleOf The multiple value allowed
|
|
62
|
+
* @decorator
|
|
63
|
+
* @validation
|
|
64
|
+
* @swagger
|
|
65
|
+
* @schema
|
|
66
|
+
* @input
|
|
67
|
+
* @ajv-errors
|
|
68
|
+
*/
|
|
69
|
+
export declare const MultipleOf: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(multipleOf: number) => (...args: any[]) => any>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a name metadata on the decorated element.
|
|
3
|
+
*
|
|
4
|
+
* ## Examples
|
|
5
|
+
* ### On parameters
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* async myMethod(@Name("nameOf") @PathParams("id") id: string): Promise<Model> {
|
|
9
|
+
*
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* ### On parameters
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @Name("AliasName")
|
|
17
|
+
* @Controller("/")
|
|
18
|
+
* class ModelCtrl {
|
|
19
|
+
*
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param name
|
|
24
|
+
* @decorator
|
|
25
|
+
* @validation
|
|
26
|
+
* @swagger
|
|
27
|
+
* @schema
|
|
28
|
+
* @input
|
|
29
|
+
* @classDecorator
|
|
30
|
+
* @operation
|
|
31
|
+
*/
|
|
32
|
+
export declare function Name(name: any): (...args: any[]) => any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { JSONSchema6TypeName } from "json-schema";
|
|
3
|
+
/**
|
|
4
|
+
* Set field as nullable.
|
|
5
|
+
*
|
|
6
|
+
* ## Example
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* class Model {
|
|
10
|
+
* @Nullable(Date)
|
|
11
|
+
* property: Date | null;
|
|
12
|
+
*
|
|
13
|
+
* @Nullable(String, Number, Boolean)
|
|
14
|
+
* property: string | number | boolean | null;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @returns {Function}
|
|
19
|
+
* @decorator
|
|
20
|
+
* @validation
|
|
21
|
+
* @swagger
|
|
22
|
+
* @schema
|
|
23
|
+
* @input
|
|
24
|
+
*/
|
|
25
|
+
export declare function Nullable(type: JSONSchema6TypeName | Type<any> | any, ...types: (JSONSchema6TypeName | Type<any> | any)[]): any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyJsonSchema } from "../../domain/JsonSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
|
4
|
+
*
|
|
5
|
+
* ::: warning
|
|
6
|
+
* OneOf isn't supported by OS2
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* @decorator
|
|
10
|
+
* @validation
|
|
11
|
+
* @swagger
|
|
12
|
+
* @schema
|
|
13
|
+
* @classDecorator
|
|
14
|
+
* @input
|
|
15
|
+
* @param oneOf
|
|
16
|
+
*/
|
|
17
|
+
export declare function OneOf(...oneOf: AnyJsonSchema[]): (...args: any[]) => any;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pattern and Pattern Properties keywords use regular expressions to express constraints.
|
|
3
|
+
* The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.
|
|
4
|
+
*
|
|
5
|
+
* ::: warning
|
|
6
|
+
* For v6 user, use @@Pattern@@ from @tsed/schema instead of @tsed/common.
|
|
7
|
+
* :::
|
|
8
|
+
*
|
|
9
|
+
* A single unicode character (other than the special characters below) matches itself.
|
|
10
|
+
*
|
|
11
|
+
* * `^`: Matches only at the beginning of the string.
|
|
12
|
+
* * `$`: Matches only at the end of the string.
|
|
13
|
+
* * `(...)`: Group a series of regular expressions into a single regular expression.
|
|
14
|
+
* * `|`: Matches either the regular expression preceding or following the | symbol.
|
|
15
|
+
* * `[abc]`: Matches any of the characters inside the square brackets.
|
|
16
|
+
* * `[a-z]`: Matches the range of characters.
|
|
17
|
+
* * `[^abc]`: Matches any character not listed.
|
|
18
|
+
* * `[^a-z]`: Matches any character outside of the range.
|
|
19
|
+
* * `+`: Matches one or more repetitions of the preceding regular expression.
|
|
20
|
+
* * `*`: Matches zero or more repetitions of the preceding regular expression.
|
|
21
|
+
* * `?`: Matches zero or one repetitions of the preceding regular expression.
|
|
22
|
+
* * `+?`, *?`, ??`: The `*`, `+`, and `?` qualifiers are all greedy; they match as much text as possible. Sometimes this behavior isn’t desired and you want to match as few characters as possible.
|
|
23
|
+
* * `{x}`: Match exactly x occurrences of the preceding regular expression.
|
|
24
|
+
* * `{x,y}`: Match at least x and at most y occurrences of the preceding regular expression.
|
|
25
|
+
* * `{x,}`: Match x occurrences or more of the preceding regular expression.
|
|
26
|
+
* * `{x}?`, {x,y}?, {x,}?`: Lazy versions of the above expressions.
|
|
27
|
+
*
|
|
28
|
+
* ## Example
|
|
29
|
+
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* class Model {
|
|
32
|
+
* @Pattern("^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$")
|
|
33
|
+
* @Pattern(/^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$/)
|
|
34
|
+
* property: string;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* ### With primitive type
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* class Model {
|
|
42
|
+
* @Pattern(/^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$/)
|
|
43
|
+
* property: string;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ```json
|
|
48
|
+
* {
|
|
49
|
+
* "type": "object",
|
|
50
|
+
* "properties": {
|
|
51
|
+
* "property": {
|
|
52
|
+
* "type": "string",
|
|
53
|
+
* "pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* ### With array type
|
|
60
|
+
*
|
|
61
|
+
* ```typescript
|
|
62
|
+
* class Model {
|
|
63
|
+
* @CollectionOf(string)
|
|
64
|
+
* @Pattern(/^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$/)
|
|
65
|
+
* property: string[];
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Will produce:
|
|
70
|
+
*
|
|
71
|
+
* ```json
|
|
72
|
+
* {
|
|
73
|
+
* "type": "object",
|
|
74
|
+
* "properties": {
|
|
75
|
+
* "property": {
|
|
76
|
+
* "type": "array",
|
|
77
|
+
* "items": {
|
|
78
|
+
* "type": "string",
|
|
79
|
+
* "pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param {string} pattern
|
|
87
|
+
* @decorator
|
|
88
|
+
* @validation
|
|
89
|
+
* @swagger
|
|
90
|
+
* @schema
|
|
91
|
+
* @input
|
|
92
|
+
* @ajv-errors
|
|
93
|
+
*/
|
|
94
|
+
export declare const Pattern: import("../../utils/withErrorMsg.js").ErrorChainedDecorator<(pattern: string | RegExp) => (...args: any[]) => any>;
|