@tsed/schema 8.0.1 → 8.0.2
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/package.json +11 -10
- package/src/components/async-api/channelsMapper.ts +81 -0
- package/src/components/async-api/generate.ts +24 -0
- package/src/components/async-api/messageMapper.ts +62 -0
- package/src/components/async-api/payloadMapper.ts +61 -0
- package/src/components/async-api/responseMapper.ts +70 -0
- package/src/components/default/anyMapper.spec.ts +7 -0
- package/src/components/default/anyMapper.ts +33 -0
- package/src/components/default/classMapper.ts +55 -0
- package/src/components/default/discriminatorMappingMapper.ts +36 -0
- package/src/components/default/enumsMapper.spec.ts +64 -0
- package/src/components/default/enumsMapper.ts +17 -0
- package/src/components/default/genericsMapper.ts +70 -0
- package/src/components/default/inheritedClassMapper.ts +24 -0
- package/src/components/default/itemMapper.ts +8 -0
- package/src/components/default/lazyRefMapper.ts +21 -0
- package/src/components/default/mapMapper.ts +25 -0
- package/src/components/default/nullableMapper.ts +55 -0
- package/src/components/default/objectMapper.ts +36 -0
- package/src/components/default/ofMapper.ts +16 -0
- package/src/components/default/propertiesMapper.ts +25 -0
- package/src/components/default/requiredMapper.ts +69 -0
- package/src/components/default/schemaMapper.ts +151 -0
- package/src/components/index.ts +36 -0
- package/src/components/open-spec/discriminatorMappingMapper.ts +7 -0
- package/src/components/open-spec/enumsMapper.ts +20 -0
- package/src/components/open-spec/generate.ts +29 -0
- package/src/components/open-spec/nullableMapper.ts +51 -0
- package/src/components/open-spec/operationInFilesMapper.ts +32 -0
- package/src/components/open-spec/operationInParameterMapper.ts +56 -0
- package/src/components/open-spec/operationInParametersMapper.ts +9 -0
- package/src/components/open-spec/operationInQueryMapper.ts +74 -0
- package/src/components/open-spec/operationMapper.ts +65 -0
- package/src/components/open-spec/operationMediaMapper.ts +11 -0
- package/src/components/open-spec/operationRequestBodyMapper.ts +82 -0
- package/src/components/open-spec/operationResponseMapper.ts +26 -0
- package/src/components/open-spec/pathsMapper.ts +132 -0
- package/src/constants/OperationVerbs.ts +29 -0
- package/src/constants/httpStatusMessages.ts +21 -0
- package/src/constants/jsonSchemaProperties.ts +17 -0
- package/src/decorators/class/children.ts +22 -0
- package/src/decorators/class/discriminatorValue.ts +53 -0
- package/src/decorators/collections/collectionContains.ts +25 -0
- package/src/decorators/collections/collectionOf.spec.ts +327 -0
- package/src/decorators/collections/collectionOf.ts +182 -0
- package/src/decorators/collections/maxItems.spec.ts +40 -0
- package/src/decorators/collections/maxItems.ts +59 -0
- package/src/decorators/collections/maxProperties.spec.ts +109 -0
- package/src/decorators/collections/maxProperties.ts +82 -0
- package/src/decorators/collections/minItems.spec.ts +40 -0
- package/src/decorators/collections/minItems.ts +63 -0
- package/src/decorators/collections/minProperties.spec.ts +109 -0
- package/src/decorators/collections/minProperties.ts +81 -0
- package/src/decorators/collections/uniqueItems.spec.ts +28 -0
- package/src/decorators/collections/uniqueItems.ts +59 -0
- package/src/decorators/common/__snapshots__/groups.spec.ts.snap +321 -0
- package/src/decorators/common/additionalProperties.spec.ts +133 -0
- package/src/decorators/common/additionalProperties.ts +17 -0
- package/src/decorators/common/allOf.spec.ts +276 -0
- package/src/decorators/common/allOf.ts +19 -0
- package/src/decorators/common/allow.spec.ts +130 -0
- package/src/decorators/common/allow.ts +50 -0
- package/src/decorators/common/any.spec.ts +109 -0
- package/src/decorators/common/any.ts +45 -0
- package/src/decorators/common/anyOf.spec.ts +270 -0
- package/src/decorators/common/anyOf.ts +23 -0
- package/src/decorators/common/const.spec.ts +98 -0
- package/src/decorators/common/const.ts +68 -0
- package/src/decorators/common/customKey.spec.ts +105 -0
- package/src/decorators/common/customKey.ts +39 -0
- package/src/decorators/common/default.spec.ts +25 -0
- package/src/decorators/common/default.ts +47 -0
- package/src/decorators/common/defaultMsg.spec.ts +22 -0
- package/src/decorators/common/defaultMsg.ts +38 -0
- package/src/decorators/common/description.spec.ts +166 -0
- package/src/decorators/common/description.ts +77 -0
- package/src/decorators/common/discriminatorKey.ts +14 -0
- package/src/decorators/common/enum.spec.ts +305 -0
- package/src/decorators/common/enum.ts +111 -0
- package/src/decorators/common/errorMsg.spec.ts +57 -0
- package/src/decorators/common/errorMsg.ts +14 -0
- package/src/decorators/common/example.spec.ts +93 -0
- package/src/decorators/common/example.ts +18 -0
- package/src/decorators/common/examples.spec.ts +101 -0
- package/src/decorators/common/examples.ts +20 -0
- package/src/decorators/common/exclusiveMaximum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMaximum.ts +75 -0
- package/src/decorators/common/exclusiveMinimum.spec.ts +47 -0
- package/src/decorators/common/exclusiveMinimum.ts +75 -0
- package/src/decorators/common/format.spec.ts +149 -0
- package/src/decorators/common/format.ts +486 -0
- package/src/decorators/common/forwardGroups.spec.ts +270 -0
- package/src/decorators/common/forwardGroups.ts +16 -0
- package/src/decorators/common/groups.spec.ts +968 -0
- package/src/decorators/common/groups.ts +66 -0
- package/src/decorators/common/hidden.spec.ts +52 -0
- package/src/decorators/common/hidden.ts +36 -0
- package/src/decorators/common/ignore.spec.ts +88 -0
- package/src/decorators/common/ignore.ts +66 -0
- package/src/decorators/common/integer.spec.ts +110 -0
- package/src/decorators/common/integer.ts +69 -0
- package/src/decorators/common/jsonEntityFn.spec.ts +16 -0
- package/src/decorators/common/jsonEntityFn.ts +33 -0
- package/src/decorators/common/maxLength.spec.ts +61 -0
- package/src/decorators/common/maxLength.ts +88 -0
- package/src/decorators/common/maximum.spec.ts +73 -0
- package/src/decorators/common/maximum.ts +146 -0
- package/src/decorators/common/minLength.spec.ts +186 -0
- package/src/decorators/common/minLength.ts +89 -0
- package/src/decorators/common/minimum.spec.ts +74 -0
- package/src/decorators/common/minimum.ts +145 -0
- package/src/decorators/common/multipleOf.spec.ts +33 -0
- package/src/decorators/common/multipleOf.ts +80 -0
- package/src/decorators/common/name.spec.ts +56 -0
- package/src/decorators/common/name.ts +50 -0
- package/src/decorators/common/nullable.spec.ts +818 -0
- package/src/decorators/common/nullable.ts +32 -0
- package/src/decorators/common/oneOf.spec.ts +301 -0
- package/src/decorators/common/oneOf.ts +24 -0
- package/src/decorators/common/optional.spec.ts +43 -0
- package/src/decorators/common/optional.ts +26 -0
- package/src/decorators/common/pattern.spec.ts +27 -0
- package/src/decorators/common/pattern.ts +102 -0
- package/src/decorators/common/property.ts +24 -0
- package/src/decorators/common/readOnly.spec.ts +135 -0
- package/src/decorators/common/readOnly.ts +17 -0
- package/src/decorators/common/recordOf.spec.ts +41 -0
- package/src/decorators/common/recordOf.ts +59 -0
- package/src/decorators/common/required.spec.ts +188 -0
- package/src/decorators/common/required.ts +50 -0
- package/src/decorators/common/requiredGroups.spec.ts +127 -0
- package/src/decorators/common/requiredGroups.ts +23 -0
- package/src/decorators/common/schema.spec.ts +23 -0
- package/src/decorators/common/schema.ts +64 -0
- package/src/decorators/common/title.spec.ts +20 -0
- package/src/decorators/common/title.ts +45 -0
- package/src/decorators/common/typeError.spec.ts +22 -0
- package/src/decorators/common/typeError.ts +15 -0
- package/src/decorators/common/writeOnly.spec.ts +105 -0
- package/src/decorators/common/writeOnly.ts +17 -0
- package/src/decorators/config/jsonEntityComponent.ts +16 -0
- package/src/decorators/generics/genericOf.spec.ts +246 -0
- package/src/decorators/generics/genericOf.ts +112 -0
- package/src/decorators/generics/generics.ts +22 -0
- package/src/decorators/operations/acceptMime.spec.ts +39 -0
- package/src/decorators/operations/acceptMime.ts +25 -0
- package/src/decorators/operations/consumes.spec.ts +89 -0
- package/src/decorators/operations/consumes.ts +37 -0
- package/src/decorators/operations/contentType.spec.ts +40 -0
- package/src/decorators/operations/contentType.ts +24 -0
- package/src/decorators/operations/deprecated.spec.ts +223 -0
- package/src/decorators/operations/deprecated.ts +49 -0
- package/src/decorators/operations/header.spec.ts +214 -0
- package/src/decorators/operations/header.ts +62 -0
- package/src/decorators/operations/in.spec.ts +321 -0
- package/src/decorators/operations/in.ts +141 -0
- package/src/decorators/operations/inFile.spec.ts +209 -0
- package/src/decorators/operations/inFile.ts +55 -0
- package/src/decorators/operations/location.spec.ts +51 -0
- package/src/decorators/operations/location.ts +26 -0
- package/src/decorators/operations/operation.ts +119 -0
- package/src/decorators/operations/operationId.spec.ts +43 -0
- package/src/decorators/operations/operationId.ts +22 -0
- package/src/decorators/operations/operationPath.spec.ts +42 -0
- package/src/decorators/operations/operationPath.ts +33 -0
- package/src/decorators/operations/partial.spec.ts +249 -0
- package/src/decorators/operations/partial.ts +14 -0
- package/src/decorators/operations/path.spec.ts +47 -0
- package/src/decorators/operations/path.ts +27 -0
- package/src/decorators/operations/produces.spec.ts +89 -0
- package/src/decorators/operations/produces.ts +44 -0
- package/src/decorators/operations/publish.spec.ts +26 -0
- package/src/decorators/operations/publish.ts +6 -0
- package/src/decorators/operations/redirect.spec.ts +146 -0
- package/src/decorators/operations/redirect.ts +82 -0
- package/src/decorators/operations/returns.spec.ts +1393 -0
- package/src/decorators/operations/returns.ts +662 -0
- package/src/decorators/operations/route.spec.ts +211 -0
- package/src/decorators/operations/route.ts +154 -0
- package/src/decorators/operations/security.spec.ts +162 -0
- package/src/decorators/operations/security.ts +83 -0
- package/src/decorators/operations/status.spec.ts +582 -0
- package/src/decorators/operations/status.ts +130 -0
- package/src/decorators/operations/subscribe.spec.ts +32 -0
- package/src/decorators/operations/subscribe.ts +6 -0
- package/src/decorators/operations/summary.spec.ts +45 -0
- package/src/decorators/operations/summary.ts +32 -0
- package/src/decorators/operations/tags.spec.ts +113 -0
- package/src/decorators/operations/tags.ts +53 -0
- package/src/decorators/operations/view.spec.ts +16 -0
- package/src/decorators/operations/view.ts +27 -0
- package/src/domain/DecoratorContext.ts +116 -0
- package/src/domain/JsonAliasMap.ts +19 -0
- package/src/domain/JsonClassStore.ts +35 -0
- package/src/domain/JsonDiscriminator.spec.ts +65 -0
- package/src/domain/JsonDiscriminator.ts +52 -0
- package/src/domain/JsonEntityStore.spec.ts +277 -0
- package/src/domain/JsonEntityStore.ts +284 -0
- package/src/domain/JsonFormatTypes.ts +17 -0
- package/src/domain/JsonLazyRef.ts +21 -0
- package/src/domain/JsonMap.spec.ts +15 -0
- package/src/domain/JsonMap.ts +33 -0
- package/src/domain/JsonMedia.ts +24 -0
- package/src/domain/JsonMethodStore.spec.ts +301 -0
- package/src/domain/JsonMethodStore.ts +212 -0
- package/src/domain/JsonOperation.spec.ts +126 -0
- package/src/domain/JsonOperation.ts +219 -0
- package/src/domain/JsonOperationPathsMap.ts +16 -0
- package/src/domain/JsonOperationRoute.spec.ts +109 -0
- package/src/domain/JsonOperationRoute.ts +75 -0
- package/src/domain/JsonParameter.ts +70 -0
- package/src/domain/JsonParameterStore.spec.ts +212 -0
- package/src/domain/JsonParameterStore.ts +138 -0
- package/src/domain/JsonParameterTypes.spec.ts +12 -0
- package/src/domain/JsonParameterTypes.ts +20 -0
- package/src/domain/JsonPropertyStore.spec.ts +177 -0
- package/src/domain/JsonPropertyStore.ts +92 -0
- package/src/domain/JsonRequestBody.ts +47 -0
- package/src/domain/JsonResponse.spec.ts +33 -0
- package/src/domain/JsonResponse.ts +64 -0
- package/src/domain/JsonSchema.spec.ts +1470 -0
- package/src/domain/JsonSchema.ts +1049 -0
- package/src/domain/SpecTypes.ts +6 -0
- package/src/hooks/alterIgnore.ts +25 -0
- package/src/hooks/alterOneOf.ts +67 -0
- package/src/hooks/alterRequiredGroups.ts +12 -0
- package/src/index.ts +185 -0
- package/src/interfaces/IgnoreCallback.ts +5 -0
- package/src/interfaces/JsonHookContext.ts +18 -0
- package/src/interfaces/JsonOpenSpec.ts +7 -0
- package/src/interfaces/JsonSchemaOptions.ts +35 -0
- package/src/registries/JsonSchemaMapperContainer.ts +52 -0
- package/src/registries/enumRegistries.ts +3 -0
- package/src/utils/__snapshots__/generateSpec.spec.ts.snap +109 -0
- package/src/utils/buildPath.ts +8 -0
- package/src/utils/concatParameters.ts +12 -0
- package/src/utils/concatPath.spec.ts +23 -0
- package/src/utils/concatPath.ts +24 -0
- package/src/utils/defineStatusModel.ts +11 -0
- package/src/utils/from.spec.ts +243 -0
- package/src/utils/from.ts +281 -0
- package/src/utils/generateSpec.spec.ts +1262 -0
- package/src/utils/generateSpec.ts +54 -0
- package/src/utils/generics.ts +83 -0
- package/src/utils/getComputedType.spec.ts +45 -0
- package/src/utils/getComputedType.ts +39 -0
- package/src/utils/getInheritedStores.spec.ts +47 -0
- package/src/utils/getInheritedStores.ts +23 -0
- package/src/utils/getJsonEntityStore.ts +36 -0
- package/src/utils/getJsonPathParameters.spec.ts +126 -0
- package/src/utils/getJsonPathParameters.ts +97 -0
- package/src/utils/getJsonSchema.spec.ts +695 -0
- package/src/utils/getJsonSchema.ts +69 -0
- package/src/utils/getJsonType.spec.ts +28 -0
- package/src/utils/getJsonType.ts +46 -0
- package/src/utils/getOperationsRoutes.spec.ts +284 -0
- package/src/utils/getOperationsRoutes.ts +56 -0
- package/src/utils/getOperationsStore.spec.ts +47 -0
- package/src/utils/getOperationsStores.ts +37 -0
- package/src/utils/getPropertiesStores.spec.ts +138 -0
- package/src/utils/getPropertiesStores.ts +66 -0
- package/src/utils/getSpec.spec.ts +610 -0
- package/src/utils/getSpec.ts +117 -0
- package/src/utils/getSpecType.spec.ts +16 -0
- package/src/utils/getSpecType.ts +19 -0
- package/src/utils/isSuccessStatus.spec.ts +22 -0
- package/src/utils/isSuccessStatus.ts +2 -0
- package/src/utils/mapHeaders.spec.ts +57 -0
- package/src/utils/mapHeaders.ts +33 -0
- package/src/utils/mapOpenSpec.ts +44 -0
- package/src/utils/mapOpenSpec2.ts +50 -0
- package/src/utils/mapOpenSpec3.ts +25 -0
- package/src/utils/mapOpenSpecInfo.ts +19 -0
- package/src/utils/mapOperationOptions.ts +34 -0
- package/src/utils/matchGroups.spec.ts +85 -0
- package/src/utils/matchGroups.ts +64 -0
- package/src/utils/mergeSpec.spec.ts +533 -0
- package/src/utils/mergeSpec.ts +54 -0
- package/src/utils/operationIdFormatter.spec.ts +11 -0
- package/src/utils/operationIdFormatter.ts +49 -0
- package/src/utils/ref.ts +65 -0
- package/src/utils/removeHiddenOperation.ts +5 -0
- package/src/utils/serializeEnumValues.ts +27 -0
- package/src/utils/somethingOf.ts +11 -0
- package/src/utils/toJsonMapCollection.spec.ts +18 -0
- package/src/utils/toJsonMapCollection.ts +12 -0
- package/src/utils/toJsonRegex.ts +7 -0
- package/src/utils/transformToOS2.spec.ts +177 -0
- package/src/utils/transformToOS2.ts +607 -0
- package/src/utils/withErrorMsg.spec.ts +16 -0
- package/src/utils/withErrorMsg.ts +56 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import {ValueOf} from "@tsed/core";
|
|
2
|
+
|
|
3
|
+
import {JsonFormatTypes} from "../../domain/JsonFormatTypes.js";
|
|
4
|
+
import {withErrorMsg} from "../../utils/withErrorMsg.js";
|
|
5
|
+
import {JsonEntityFn} from "./jsonEntityFn.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The following formats are supported for string validation with `format` keyword:
|
|
9
|
+
*
|
|
10
|
+
* - **date**: full-date according to [RFC3339](https://json-schema.org/latest/json-schema-validation.html#RFC3339).
|
|
11
|
+
* - **time**: time with optional time-zone.
|
|
12
|
+
* - **date-time**: date-time from the same source (time-zone is mandatory).
|
|
13
|
+
* - **uri**: full uri with optional protocol.
|
|
14
|
+
* - **email**: email address.
|
|
15
|
+
* - **hostname**: host name according to [RFC1034](https://tools.ietf.org/html/rfc1034#section-3.1).
|
|
16
|
+
* - **ipv4**: IP address v4.
|
|
17
|
+
* - **ipv6**: IP address v6.
|
|
18
|
+
* - **regex**: tests whether a string is a valid regular expression by passing it to RegExp constructor.
|
|
19
|
+
*
|
|
20
|
+
* ::: warning
|
|
21
|
+
* For v6 user, use @@Format@@ from @tsed/schema instead of @tsed/platform-http.
|
|
22
|
+
* :::
|
|
23
|
+
*
|
|
24
|
+
* ## Example
|
|
25
|
+
* ### With primitive type
|
|
26
|
+
*
|
|
27
|
+
* ```typescript
|
|
28
|
+
* class Model {
|
|
29
|
+
* @Format("email")
|
|
30
|
+
* property: string;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ```json
|
|
35
|
+
* {
|
|
36
|
+
* "type": "object",
|
|
37
|
+
* "properties": {
|
|
38
|
+
* "property": {
|
|
39
|
+
* "type": "string",
|
|
40
|
+
* "format": "email"
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* ### With array type
|
|
47
|
+
*
|
|
48
|
+
* ```typescript
|
|
49
|
+
* class Model {
|
|
50
|
+
* @Format("email")
|
|
51
|
+
* @CollectionOf(String)
|
|
52
|
+
* property: string[];
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Will produce:
|
|
57
|
+
*
|
|
58
|
+
* ```json
|
|
59
|
+
* {
|
|
60
|
+
* "type": "object",
|
|
61
|
+
* "properties": {
|
|
62
|
+
* "property": {
|
|
63
|
+
* "type": "array",
|
|
64
|
+
* "items": {
|
|
65
|
+
* "type": "string",
|
|
66
|
+
* "format": "email"
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param {string} format
|
|
74
|
+
* @decorator
|
|
75
|
+
* @validation
|
|
76
|
+
* @swagger
|
|
77
|
+
* @schema
|
|
78
|
+
* @input
|
|
79
|
+
* @ajv-errors
|
|
80
|
+
*/
|
|
81
|
+
export const Format = withErrorMsg("format", (format: JsonFormatTypes | ValueOf<JsonFormatTypes>) => {
|
|
82
|
+
return JsonEntityFn((store) => {
|
|
83
|
+
store.itemSchema.format(format);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Apply an email validation on property.
|
|
89
|
+
*
|
|
90
|
+
* ::: warning
|
|
91
|
+
* For v6 user, use @@Email@@ from @tsed/schema instead of @tsed/platform-http.
|
|
92
|
+
* :::
|
|
93
|
+
*
|
|
94
|
+
* ## Example
|
|
95
|
+
* ### With primitive type
|
|
96
|
+
*
|
|
97
|
+
* ```typescript
|
|
98
|
+
* class Model {
|
|
99
|
+
* @Email()
|
|
100
|
+
* property: string;
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* Will produce:
|
|
105
|
+
*
|
|
106
|
+
* ```json
|
|
107
|
+
* {
|
|
108
|
+
* "type": "object",
|
|
109
|
+
* "properties": {
|
|
110
|
+
* "property": {
|
|
111
|
+
* "type": "string",
|
|
112
|
+
* "format": "email"
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* ### With array type
|
|
119
|
+
*
|
|
120
|
+
* ```typescript
|
|
121
|
+
* class Model {
|
|
122
|
+
* @Email()
|
|
123
|
+
* @CollectionOf(String)
|
|
124
|
+
* property: string[];
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* Will produce:
|
|
129
|
+
*
|
|
130
|
+
* ```json
|
|
131
|
+
* {
|
|
132
|
+
* "type": "object",
|
|
133
|
+
* "properties": {
|
|
134
|
+
* "property": {
|
|
135
|
+
* "type": "array",
|
|
136
|
+
* "items": {
|
|
137
|
+
* "type": "string",
|
|
138
|
+
* "format": "email"
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
* }
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @returns {Function}
|
|
146
|
+
* @decorator
|
|
147
|
+
* @validation
|
|
148
|
+
* @schema
|
|
149
|
+
* @swagger
|
|
150
|
+
* @input
|
|
151
|
+
* @ajv-errors
|
|
152
|
+
*/
|
|
153
|
+
export const Email = withErrorMsg("format", () => {
|
|
154
|
+
return Format(JsonFormatTypes.EMAIL);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Apply a date-time validation on property.
|
|
159
|
+
*
|
|
160
|
+
* ## Example
|
|
161
|
+
* ### With primitive type
|
|
162
|
+
*
|
|
163
|
+
* ```typescript
|
|
164
|
+
* class Model {
|
|
165
|
+
* @DateTime()
|
|
166
|
+
* property: string;
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* Will produce:
|
|
171
|
+
*
|
|
172
|
+
* ```json
|
|
173
|
+
* {
|
|
174
|
+
* "type": "object",
|
|
175
|
+
* "properties": {
|
|
176
|
+
* "property": {
|
|
177
|
+
* "type": "string",
|
|
178
|
+
* "format": "date-time"
|
|
179
|
+
* }
|
|
180
|
+
* }
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* ### With array type
|
|
185
|
+
*
|
|
186
|
+
* ```typescript
|
|
187
|
+
* class Model {
|
|
188
|
+
* @DateTime()
|
|
189
|
+
* @CollectionOf(String)
|
|
190
|
+
* property: string[];
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* Will produce:
|
|
195
|
+
*
|
|
196
|
+
* ```json
|
|
197
|
+
* {
|
|
198
|
+
* "type": "object",
|
|
199
|
+
* "properties": {
|
|
200
|
+
* "property": {
|
|
201
|
+
* "type": "array",
|
|
202
|
+
* "items": {
|
|
203
|
+
* "type": "string",
|
|
204
|
+
* "format": "date-time"
|
|
205
|
+
* }
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @returns {Function}
|
|
212
|
+
* @decorator
|
|
213
|
+
* @validation
|
|
214
|
+
* @property
|
|
215
|
+
* @parameter
|
|
216
|
+
* @schema
|
|
217
|
+
* @auto-map The data will be stored on the right place according to the type and collectionType (primitive or collection).
|
|
218
|
+
* @ajv-errors
|
|
219
|
+
*/
|
|
220
|
+
export const DateTime = withErrorMsg("format", () => {
|
|
221
|
+
return Format(JsonFormatTypes.DATE_TIME);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Apply a time validation on property.
|
|
226
|
+
*
|
|
227
|
+
* ## Example
|
|
228
|
+
* ### With primitive type
|
|
229
|
+
*
|
|
230
|
+
* ```typescript
|
|
231
|
+
* class Model {
|
|
232
|
+
* @Time()
|
|
233
|
+
* property: string;
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* Will produce:
|
|
238
|
+
*
|
|
239
|
+
* ```json
|
|
240
|
+
* {
|
|
241
|
+
* "type": "object",
|
|
242
|
+
* "properties": {
|
|
243
|
+
* "property": {
|
|
244
|
+
* "type": "string",
|
|
245
|
+
* "format": "time"
|
|
246
|
+
* }
|
|
247
|
+
* }
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* ### With array type
|
|
252
|
+
*
|
|
253
|
+
* ```typescript
|
|
254
|
+
* class Model {
|
|
255
|
+
* @Time()
|
|
256
|
+
* @CollectionOf(String)
|
|
257
|
+
* property: string[];
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* Will produce:
|
|
262
|
+
*
|
|
263
|
+
* ```json
|
|
264
|
+
* {
|
|
265
|
+
* "type": "object",
|
|
266
|
+
* "properties": {
|
|
267
|
+
* "property": {
|
|
268
|
+
* "type": "array",
|
|
269
|
+
* "items": {
|
|
270
|
+
* "type": "string",
|
|
271
|
+
* "format": "time"
|
|
272
|
+
* }
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* }
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @returns {Function}
|
|
279
|
+
* @decorator
|
|
280
|
+
* @validation
|
|
281
|
+
* @property
|
|
282
|
+
* @parameter
|
|
283
|
+
* @schema
|
|
284
|
+
* @ajv-errors
|
|
285
|
+
*/
|
|
286
|
+
export const DateFormat = withErrorMsg("format", () => {
|
|
287
|
+
return Format(JsonFormatTypes.DATE);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Apply a time validation on property.
|
|
292
|
+
*
|
|
293
|
+
* ## Example
|
|
294
|
+
* ### With primitive type
|
|
295
|
+
*
|
|
296
|
+
* ```typescript
|
|
297
|
+
* class Model {
|
|
298
|
+
* @TimeFormat()
|
|
299
|
+
* property: string;
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* Will produce:
|
|
304
|
+
*
|
|
305
|
+
* ```json
|
|
306
|
+
* {
|
|
307
|
+
* "type": "object",
|
|
308
|
+
* "properties": {
|
|
309
|
+
* "property": {
|
|
310
|
+
* "type": "string",
|
|
311
|
+
* "format": "time"
|
|
312
|
+
* }
|
|
313
|
+
* }
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* ### With array type
|
|
318
|
+
*
|
|
319
|
+
* ```typescript
|
|
320
|
+
* class Model {
|
|
321
|
+
* @TimeFormat()
|
|
322
|
+
* @CollectionOf(String)
|
|
323
|
+
* property: string[];
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* Will produce:
|
|
328
|
+
*
|
|
329
|
+
* ```json
|
|
330
|
+
* {
|
|
331
|
+
* "type": "object",
|
|
332
|
+
* "properties": {
|
|
333
|
+
* "property": {
|
|
334
|
+
* "type": "array",
|
|
335
|
+
* "items": {
|
|
336
|
+
* "type": "string",
|
|
337
|
+
* "format": "time"
|
|
338
|
+
* }
|
|
339
|
+
* }
|
|
340
|
+
* }
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @returns {Function}
|
|
345
|
+
* @decorator
|
|
346
|
+
* @validation
|
|
347
|
+
* @property
|
|
348
|
+
* @parameter
|
|
349
|
+
* @schema
|
|
350
|
+
* @ajv-errors
|
|
351
|
+
*/
|
|
352
|
+
export const TimeFormat = withErrorMsg("format", () => {
|
|
353
|
+
return Format(JsonFormatTypes.TIME);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Apply a uri validation on property.
|
|
358
|
+
*
|
|
359
|
+
* ## Example
|
|
360
|
+
* ### With primitive type
|
|
361
|
+
*
|
|
362
|
+
* ```typescript
|
|
363
|
+
* class Model {
|
|
364
|
+
* @Uri()
|
|
365
|
+
* property: string;
|
|
366
|
+
* }
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* Will produce:
|
|
370
|
+
*
|
|
371
|
+
* ```json
|
|
372
|
+
* {
|
|
373
|
+
* "type": "object",
|
|
374
|
+
* "properties": {
|
|
375
|
+
* "property": {
|
|
376
|
+
* "type": "string",
|
|
377
|
+
* "format": "uri"
|
|
378
|
+
* }
|
|
379
|
+
* }
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* ### With array type
|
|
384
|
+
*
|
|
385
|
+
* ```typescript
|
|
386
|
+
* class Model {
|
|
387
|
+
* @Uri()
|
|
388
|
+
* @CollectionOf(String)
|
|
389
|
+
* property: string[];
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* Will produce:
|
|
394
|
+
*
|
|
395
|
+
* ```json
|
|
396
|
+
* {
|
|
397
|
+
* "type": "object",
|
|
398
|
+
* "properties": {
|
|
399
|
+
* "property": {
|
|
400
|
+
* "type": "array",
|
|
401
|
+
* "items": {
|
|
402
|
+
* "type": "string",
|
|
403
|
+
* "format": "uri"
|
|
404
|
+
* }
|
|
405
|
+
* }
|
|
406
|
+
* }
|
|
407
|
+
* }
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* @returns {Function}
|
|
411
|
+
* @decorator
|
|
412
|
+
* @validation
|
|
413
|
+
* @property
|
|
414
|
+
* @parameter
|
|
415
|
+
* @schema
|
|
416
|
+
* @ajv-errors
|
|
417
|
+
*/
|
|
418
|
+
export const Uri = withErrorMsg("format", () => {
|
|
419
|
+
return Format(JsonFormatTypes.URI);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Apply a url validation on property.
|
|
424
|
+
*
|
|
425
|
+
* ## Example
|
|
426
|
+
* ### With primitive type
|
|
427
|
+
*
|
|
428
|
+
* ```typescript
|
|
429
|
+
* class Model {
|
|
430
|
+
* @Url()
|
|
431
|
+
* property: string;
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* Will produce:
|
|
436
|
+
*
|
|
437
|
+
* ```json
|
|
438
|
+
* {
|
|
439
|
+
* "type": "object",
|
|
440
|
+
* "properties": {
|
|
441
|
+
* "property": {
|
|
442
|
+
* "type": "string",
|
|
443
|
+
* "format": "url"
|
|
444
|
+
* }
|
|
445
|
+
* }
|
|
446
|
+
* }
|
|
447
|
+
* ```
|
|
448
|
+
*
|
|
449
|
+
* ### With array type
|
|
450
|
+
*
|
|
451
|
+
* ```typescript
|
|
452
|
+
* class Model {
|
|
453
|
+
* @Url()
|
|
454
|
+
* @CollectionOf(String)
|
|
455
|
+
* property: string[];
|
|
456
|
+
* }
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* Will produce:
|
|
460
|
+
*
|
|
461
|
+
* ```json
|
|
462
|
+
* {
|
|
463
|
+
* "type": "object",
|
|
464
|
+
* "properties": {
|
|
465
|
+
* "property": {
|
|
466
|
+
* "type": "array",
|
|
467
|
+
* "items": {
|
|
468
|
+
* "type": "string",
|
|
469
|
+
* "format": "url"
|
|
470
|
+
* }
|
|
471
|
+
* }
|
|
472
|
+
* }
|
|
473
|
+
* }
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* @returns {Function}
|
|
477
|
+
* @decorator
|
|
478
|
+
* @validation
|
|
479
|
+
* @property
|
|
480
|
+
* @parameter
|
|
481
|
+
* @schema
|
|
482
|
+
* @ajv-errors
|
|
483
|
+
*/
|
|
484
|
+
export const Url = withErrorMsg("format", () => {
|
|
485
|
+
return Format(JsonFormatTypes.URL);
|
|
486
|
+
});
|