nfx-serialization 0.3.0
Cross-platform C++ JSON serialization library with extensible trait capabilities
Loading...
Searching...
No Matches
Vocabulary.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 nfx
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
32
33#pragma once
34
35#include <string_view>
36
37namespace nfx::serialization::json::vocabulary
38{
39 //=====================================================================
40 // JSON Schema Draft URIs
41 //=====================================================================
42
44 inline constexpr std::string_view SCHEMA_DRAFT_2020_12{ "https://json-schema.org/draft/2020-12/schema" };
45
47 inline constexpr std::string_view SCHEMA_DRAFT_2019_09{ "https://json-schema.org/draft/2019-09/schema" };
48
50 inline constexpr std::string_view SCHEMA_DRAFT_07{ "http://json-schema.org/draft-07/schema#" };
51
53 inline constexpr std::string_view SCHEMA_DRAFT_06{ "http://json-schema.org/draft-06/schema#" };
54
56 inline constexpr std::string_view SCHEMA_DRAFT_04{ "http://json-schema.org/draft-04/schema#" };
57
58 //=====================================================================
59 // JSON vocabulary
60 //=====================================================================
61
62 //----------------------------------------------
63 // Core
64 //----------------------------------------------
65
67 inline constexpr std::string_view CORE_ID{ "$id" };
68
70 inline constexpr std::string_view CORE_SCHEMA{ "$schema" };
71
73 inline constexpr std::string_view CORE_REF{ "$ref" };
74
76 inline constexpr std::string_view CORE_COMMENT{ "$comment" };
77
79 inline constexpr std::string_view CORE_DEFS{ "$defs" };
80
82 inline constexpr std::string_view CORE_ANCHOR{ "$anchor" };
83
85 inline constexpr std::string_view CORE_DYNAMIC_ANCHOR{ "$dynamicAnchor" };
86
88 inline constexpr std::string_view CORE_DYNAMIC_REF{ "$dynamicRef" };
89
91 inline constexpr std::string_view CORE_VOCABULARY{ "$vocabulary" };
92
93 //----------------------------------------------
94 // Applicator
95 //----------------------------------------------
96
98 inline constexpr std::string_view APPLICATOR_ALL_OF{ "allOf" };
99
101 inline constexpr std::string_view APPLICATOR_ANY_OF{ "anyOf" };
102
104 inline constexpr std::string_view APPLICATOR_ONE_OF{ "oneOf" };
105
107 inline constexpr std::string_view APPLICATOR_IF{ "if" };
108
110 inline constexpr std::string_view APPLICATOR_THEN{ "then" };
111
113 inline constexpr std::string_view APPLICATOR_ELSE{ "else" };
114
116 inline constexpr std::string_view APPLICATOR_NOT{ "not" };
117
119 inline constexpr std::string_view APPLICATOR_PROPERTIES{ "properties" };
120
122 inline constexpr std::string_view APPLICATOR_ADDITIONAL_PROPERTIES{ "additionalProperties" };
123
125 inline constexpr std::string_view APPLICATOR_PATTERN_PROPERTIES{ "patternProperties" };
126
128 inline constexpr std::string_view APPLICATOR_DEPENDENT_SCHEMAS{ "dependentSchemas" };
129
131 inline constexpr std::string_view APPLICATOR_PROPERTY_NAMES{ "propertyNames" };
132
134 inline constexpr std::string_view APPLICATOR_CONTAINS{ "contains" };
135
137 inline constexpr std::string_view APPLICATOR_ITEMS{ "items" };
138
140 inline constexpr std::string_view APPLICATOR_PREFIX_ITEMS{ "prefixItems" };
141
142 //----------------------------------------------
143 // Defined formats (JSON Schema Draft 2020-12 Section 7.3)
144 //----------------------------------------------
145
146 //-----------------------------
147 // Dates, Times, and Duration (RFC 3339)
148 //-----------------------------
149
151 inline constexpr std::string_view FORMAT_DATETIME{ "date-time" };
152
154 inline constexpr std::string_view FORMAT_DATE{ "date" };
155
157 inline constexpr std::string_view FORMAT_TIME{ "time" };
158
160 inline constexpr std::string_view FORMAT_DURATION{ "duration" };
161
162 //-----------------------------
163 // Email Addresses (RFC 5321/6531)
164 //-----------------------------
165
167 inline constexpr std::string_view FORMAT_EMAIL{ "email" };
168
170 inline constexpr std::string_view FORMAT_IDN_EMAIL{ "idn-email" };
171
172 //-----------------------------
173 // Hostnames (RFC 1123/5890)
174 //-----------------------------
175
177 inline constexpr std::string_view FORMAT_HOSTNAME{ "hostname" };
178
180 inline constexpr std::string_view FORMAT_IDN_HOSTNAME{ "idn-hostname" };
181
182 //-----------------------------
183 // IP Addresses (RFC 2673/4291)
184 //-----------------------------
185
187 inline constexpr std::string_view FORMAT_IPV4{ "ipv4" };
188
190 inline constexpr std::string_view FORMAT_IPV6{ "ipv6" };
191
192 //-----------------------------
193 // Resource Identifiers (RFC 3986/3987/4122)
194 //-----------------------------
195
197 inline constexpr std::string_view FORMAT_URI{ "uri" };
198
200 inline constexpr std::string_view FORMAT_URI_REFERENCE{ "uri-reference" };
201
203 inline constexpr std::string_view FORMAT_IRI{ "iri" };
204
206 inline constexpr std::string_view FORMAT_IRI_REFERENCE{ "iri-reference" };
207
209 inline constexpr std::string_view FORMAT_UUID{ "uuid" };
210
211 //-----------------------------
212 // URI Template (RFC 6570)
213 //-----------------------------
214
216 inline constexpr std::string_view FORMAT_URI_TEMPLATE{ "uri-template" };
217
218 //-----------------------------
219 // JSON Pointers (RFC 6901)
220 //-----------------------------
221
223 inline constexpr std::string_view FORMAT_JSON_POINTER{ "json-pointer" };
224
226 inline constexpr std::string_view FORMAT_RELATIVE_JSON_POINTER{ "relative-json-pointer" };
227
228 //-----------------------------
229 // Regex (ECMA-262)
230 //-----------------------------
231
233 inline constexpr std::string_view FORMAT_REGEX{ "regex" };
234
235 //----------------------------------------------
236 // Validation
237 //----------------------------------------------
238
239 //-----------------------------
240 // General validation
241 //-----------------------------
242
244 inline constexpr std::string_view VALIDATION_TYPE{ "type" };
245
247 inline constexpr std::string_view VALIDATION_ENUM{ "enum" };
248
250 inline constexpr std::string_view VALIDATION_CONST{ "const" };
251
252 //-----------------------------
254 //-----------------------------
255
257 inline constexpr std::string_view VALIDATION_MAX_LENGTH{ "maxLength" };
258
260 inline constexpr std::string_view VALIDATION_MIN_LENGTH{ "minLength" };
261
263 inline constexpr std::string_view VALIDATION_PATTERN{ "pattern" };
264
265 //-----------------------------
267 //-----------------------------
268
270 inline constexpr std::string_view VALIDATION_MAXIMUM{ "maximum" };
271
273 inline constexpr std::string_view VALIDATION_MINIMUM{ "minimum" };
274
276 inline constexpr std::string_view VALIDATION_EXCLUSIVE_MAXIMUM{ "exclusiveMaximum" };
277
279 inline constexpr std::string_view VALIDATION_EXCLUSIVE_MINIMUM{ "exclusiveMinimum" };
280
282 inline constexpr std::string_view VALIDATION_MULTIPLE_OF{ "multipleOf" };
283
284 //-----------------------------
286 //-----------------------------
287
289 inline constexpr std::string_view VALIDATION_MAX_PROPERTIES{ "maxProperties" };
290
292 inline constexpr std::string_view VALIDATION_MIN_PROPERTIES{ "minProperties" };
293
295 inline constexpr std::string_view VALIDATION_REQUIRED{ "required" };
296
298 inline constexpr std::string_view VALIDATION_DEPENDENT_REQUIRED{ "dependentRequired" };
299
300 //-----------------------------
302 //-----------------------------
303
305 inline constexpr std::string_view VALIDATION_MAX_ITEMS{ "maxItems" };
306
308 inline constexpr std::string_view VALIDATION_MIN_ITEMS{ "minItems" };
309
311 inline constexpr std::string_view VALIDATION_MAX_CONTAINS{ "maxContains" };
312
314 inline constexpr std::string_view VALIDATION_MIN_CONTAINS{ "minContains" };
315
317 inline constexpr std::string_view VALIDATION_UNIQUE_ITEMS{ "uniqueItems" };
318
319 //----------------------------------------------
320 // Meta data
321 //----------------------------------------------
322
324 inline constexpr std::string_view METADATA_TITLE{ "title" };
325
327 inline constexpr std::string_view METADATA_DESCRIPTION{ "description" };
328
330 inline constexpr std::string_view METADATA_DEFAULT{ "default" };
331
333 inline constexpr std::string_view METADATA_DEPRECATED{ "deprecated" };
334
336 inline constexpr std::string_view METADATA_EXAMPLES{ "examples" };
337
339 inline constexpr std::string_view METADATA_READ_ONLY{ "readOnly" };
340
342 inline constexpr std::string_view METADATA_WRITE_ONLY{ "writeOnly" };
343
344 //----------------------------------------------
345 // Format annotation
346 //----------------------------------------------
347
349 inline constexpr std::string_view FORMAT_ANNOTATION{ "format" };
350
351 //----------------------------------------------
352 // Content
353 //----------------------------------------------
354
356 inline constexpr std::string_view CONTENT_ENCODING{ "contentEncoding" };
357
359 inline constexpr std::string_view CONTENT_MEDIA_TYPE{ "contentMediaType" };
360
362 inline constexpr std::string_view CONTENT_SCHEMA{ "contentSchema" };
363
364 //----------------------------------------------
365 // Unevaluated
366 //----------------------------------------------
367
369 inline constexpr std::string_view UNEVALUATED_ITEMS{ "unevaluatedItems" };
370
372 inline constexpr std::string_view UNEVALUATED_PROPERTIES{ "unevaluatedProperties" };
373
374 //----------------------------------------------
375 // Format assertion
376 //----------------------------------------------
377
379 inline constexpr std::string_view FORMAT_ASSERTION{ "format" };
380} // namespace nfx::serialization::json::vocabulary
constexpr std::string_view FORMAT_UUID
A string instance is valid if it is a valid string representation of a UUID according to RFC 4122.
Definition Vocabulary.h:209
constexpr std::string_view VALIDATION_MAX_ITEMS
Array validation.
Definition Vocabulary.h:305
constexpr std::string_view VALIDATION_UNIQUE_ITEMS
If this keyword is set to the boolean value true, the instance validates successfully if all of its e...
Definition Vocabulary.h:317
constexpr std::string_view CONTENT_SCHEMA
This keyword declares a schema which describes the structure of the string.
Definition Vocabulary.h:362
constexpr std::string_view APPLICATOR_PROPERTIES
Validation succeeds if, for each name that appears in both the instance and as a name within this key...
Definition Vocabulary.h:119
constexpr std::string_view APPLICATOR_ANY_OF
An instance validates successfully against this keyword if it validates successfully against at least...
Definition Vocabulary.h:101
constexpr std::string_view METADATA_DEFAULT
This keyword can be used to supply a default JSON value associated with a particular schema.
Definition Vocabulary.h:330
constexpr std::string_view FORMAT_RELATIVE_JSON_POINTER
A string instance is valid if it is a valid Relative JSON Pointer.
Definition Vocabulary.h:226
constexpr std::string_view SCHEMA_DRAFT_2019_09
JSON Schema Draft 2019-09 URI.
Definition Vocabulary.h:47
constexpr std::string_view APPLICATOR_NOT
An instance is valid against this keyword if it fails to validate successfully against the schema def...
Definition Vocabulary.h:116
constexpr std::string_view VALIDATION_ENUM
Validation succeeds if the instance is equal to one of the elements in this keyword's array value.
Definition Vocabulary.h:247
constexpr std::string_view METADATA_EXAMPLES
This keyword is used to provide sample JSON values associated with a particular schema,...
Definition Vocabulary.h:336
constexpr std::string_view FORMAT_URI
A string instance is valid if it is a valid URI according to RFC 3986.
Definition Vocabulary.h:197
constexpr std::string_view FORMAT_HOSTNAME
A string instance is valid if it is a valid representation for an Internet hostname as defined by RFC...
Definition Vocabulary.h:177
constexpr std::string_view SCHEMA_DRAFT_04
JSON Schema Draft-04 URI.
Definition Vocabulary.h:56
constexpr std::string_view FORMAT_DATETIME
A string instance is valid if it is a valid representation according to the "date-time" ABNF rule.
Definition Vocabulary.h:151
constexpr std::string_view VALIDATION_MAXIMUM
Numeric validation.
Definition Vocabulary.h:270
constexpr std::string_view CORE_ID
This keyword declares an identifier for the schema resource.
Definition Vocabulary.h:67
constexpr std::string_view FORMAT_IRI_REFERENCE
A string instance is valid if it is a valid IRI Reference (either an IRI or a relative-reference) acc...
Definition Vocabulary.h:206
constexpr std::string_view VALIDATION_MIN_PROPERTIES
An object instance is valid if its number of properties is greater than, or equal to,...
Definition Vocabulary.h:292
constexpr std::string_view CORE_DYNAMIC_REF
This keyword is used to reference an identified schema, deferring the full resolution until runtime,...
Definition Vocabulary.h:88
constexpr std::string_view APPLICATOR_CONTAINS
Validation succeeds if the instance contains an element that validates against this schema.
Definition Vocabulary.h:134
constexpr std::string_view FORMAT_URI_TEMPLATE
A string instance is valid if it is a valid URI Template (of any level) according to RFC 6570.
Definition Vocabulary.h:216
constexpr std::string_view CONTENT_ENCODING
The string instance should be interpreted as encoded binary data and decoded using the encoding named...
Definition Vocabulary.h:356
constexpr std::string_view UNEVALUATED_ITEMS
Validates array elements that did not successfully validate against other standard array applicators.
Definition Vocabulary.h:369
constexpr std::string_view FORMAT_TIME
A string instance is valid if it is a valid representation according to the "full-time" ABNF rule.
Definition Vocabulary.h:157
constexpr std::string_view APPLICATOR_ALL_OF
An instance validates successfully against this keyword if it validates successfully against all sche...
Definition Vocabulary.h:98
constexpr std::string_view FORMAT_IPV4
A string instance is valid if it is a valid IPv4 address according to the "dotted-quad" ABNF syntax a...
Definition Vocabulary.h:187
constexpr std::string_view FORMAT_IRI
A string instance is valid if it is a valid IRI according to RFC 3987.
Definition Vocabulary.h:203
constexpr std::string_view CONTENT_MEDIA_TYPE
This keyword declares the media type of the string instance.
Definition Vocabulary.h:359
constexpr std::string_view CORE_DEFS
This keyword reserves a location for schema authors to inline reusable JSON Schemas into a more gener...
Definition Vocabulary.h:79
constexpr std::string_view APPLICATOR_ONE_OF
An instance validates successfully against this keyword if it validates successfully against exactly ...
Definition Vocabulary.h:104
constexpr std::string_view FORMAT_JSON_POINTER
A string instance is valid if it is a valid JSON string representation of a JSON Pointer according to...
Definition Vocabulary.h:223
constexpr std::string_view FORMAT_IDN_EMAIL
A string instance is valid if it is a valid internationalized email address as defined by RFC 6531,...
Definition Vocabulary.h:170
constexpr std::string_view APPLICATOR_ELSE
When if is present, and the instance fails to validate against its subschema, then validation succeed...
Definition Vocabulary.h:113
constexpr std::string_view METADATA_WRITE_ONLY
This keyword indicates that the value is never present when the instance is retrieved from the owning...
Definition Vocabulary.h:342
constexpr std::string_view VALIDATION_MULTIPLE_OF
A numeric instance is valid only if division by this keyword's value results in an integer.
Definition Vocabulary.h:282
constexpr std::string_view APPLICATOR_ADDITIONAL_PROPERTIES
Validation succeeds if the schema validates against each value not matched by other object applicator...
Definition Vocabulary.h:122
constexpr std::string_view VALIDATION_MIN_CONTAINS
The number of times that the contains keyword (if set) successfully validates against the instance mu...
Definition Vocabulary.h:314
constexpr std::string_view METADATA_DEPRECATED
This keyword indicates that applications should refrain from using the declared property.
Definition Vocabulary.h:333
constexpr std::string_view VALIDATION_EXCLUSIVE_MINIMUM
Validation succeeds if the numeric instance is greater than the given number.
Definition Vocabulary.h:279
constexpr std::string_view FORMAT_REGEX
A regular expression which should be valid according to the ECMA-262 regular expression dialect.
Definition Vocabulary.h:233
constexpr std::string_view VALIDATION_MAX_LENGTH
String validation.
Definition Vocabulary.h:257
constexpr std::string_view VALIDATION_REQUIRED
An object instance is valid against this keyword if every item in the array is the name of a property...
Definition Vocabulary.h:295
constexpr std::string_view CORE_ANCHOR
This keyword is used to create plain name fragments that are not tied to any particular structural lo...
Definition Vocabulary.h:82
constexpr std::string_view APPLICATOR_THEN
When if is present, and the instance successfully validates against its subschema,...
Definition Vocabulary.h:110
constexpr std::string_view CORE_DYNAMIC_ANCHOR
This keyword is used to create plain name fragments that are not tied to any particular structural lo...
Definition Vocabulary.h:85
constexpr std::string_view FORMAT_DATE
A string instance is valid if it is a valid representation according to the "full-date" ABNF rule.
Definition Vocabulary.h:154
constexpr std::string_view SCHEMA_DRAFT_06
JSON Schema Draft-06 URI.
Definition Vocabulary.h:53
constexpr std::string_view APPLICATOR_PROPERTY_NAMES
Validation succeeds if the schema validates against every property name in the instance.
Definition Vocabulary.h:131
constexpr std::string_view VALIDATION_MAX_CONTAINS
The number of times that the contains keyword (if set) successfully validates against the instance mu...
Definition Vocabulary.h:311
constexpr std::string_view VALIDATION_MINIMUM
Validation succeeds if the numeric instance is greater than or equal to the given number.
Definition Vocabulary.h:273
constexpr std::string_view VALIDATION_EXCLUSIVE_MAXIMUM
Validation succeeds if the numeric instance is less than the given number.
Definition Vocabulary.h:276
constexpr std::string_view APPLICATOR_PATTERN_PROPERTIES
Validation succeeds if, for each instance name that matches any regular expressions that appear as a ...
Definition Vocabulary.h:125
constexpr std::string_view FORMAT_ASSERTION
Define and assert semantic information about a string instance.
Definition Vocabulary.h:379
constexpr std::string_view FORMAT_EMAIL
A string instance is valid if it is a valid Internet email address as defined by RFC 5321,...
Definition Vocabulary.h:167
constexpr std::string_view FORMAT_IPV6
A string instance is valid if it is a valid IPv6 address as defined in RFC 4291, section 2....
Definition Vocabulary.h:190
constexpr std::string_view FORMAT_URI_REFERENCE
A string instance is valid if it is a valid URI Reference (either a URI or a relative-reference) acco...
Definition Vocabulary.h:200
constexpr std::string_view VALIDATION_MIN_ITEMS
An array instance is valid if its size is greater than, or equal to, the value of this keyword.
Definition Vocabulary.h:308
constexpr std::string_view APPLICATOR_DEPENDENT_SCHEMAS
This keyword specifies subschemas that are evaluated if the instance is an object and contains a cert...
Definition Vocabulary.h:128
constexpr std::string_view FORMAT_IDN_HOSTNAME
A string instance is valid if it is a valid internationalized hostname as defined by RFC 5890,...
Definition Vocabulary.h:180
constexpr std::string_view FORMAT_ANNOTATION
Define semantic information about a string instance.
Definition Vocabulary.h:349
constexpr std::string_view VALIDATION_CONST
Validation succeeds if the instance is equal to this keyword's value.
Definition Vocabulary.h:250
constexpr std::string_view VALIDATION_DEPENDENT_REQUIRED
Validation succeeds if, for each name that appears in both the instance and as a name within this key...
Definition Vocabulary.h:298
constexpr std::string_view VALIDATION_MIN_LENGTH
A string instance is valid against this keyword if its length is greater than, or equal to,...
Definition Vocabulary.h:260
constexpr std::string_view CORE_REF
This keyword is used to reference a statically identified schema.
Definition Vocabulary.h:73
constexpr std::string_view CORE_SCHEMA
This keyword is both used as a JSON Schema dialect identifier and as a reference to a JSON Schema whi...
Definition Vocabulary.h:70
constexpr std::string_view APPLICATOR_IF
This keyword declares a condition based on the validation result of the given schema.
Definition Vocabulary.h:107
constexpr std::string_view CORE_VOCABULARY
This keyword is used in dialect meta-schemas to identify the required and optional vocabularies avail...
Definition Vocabulary.h:91
constexpr std::string_view VALIDATION_PATTERN
A string instance is considered valid if the regular expression matches the instance successfully.
Definition Vocabulary.h:263
constexpr std::string_view APPLICATOR_PREFIX_ITEMS
Validation succeeds if each element of the instance validates against the schema at the same position...
Definition Vocabulary.h:140
constexpr std::string_view UNEVALUATED_PROPERTIES
Validates object properties that did not successfully validate against other standard object applicat...
Definition Vocabulary.h:372
constexpr std::string_view SCHEMA_DRAFT_07
JSON Schema Draft-07 URI.
Definition Vocabulary.h:50
constexpr std::string_view CORE_COMMENT
This keyword reserves a location for comments from schema authors to readers or maintainers of the sc...
Definition Vocabulary.h:76
constexpr std::string_view APPLICATOR_ITEMS
Validation succeeds if each element of the instance not covered by prefixItems validates against this...
Definition Vocabulary.h:137
constexpr std::string_view FORMAT_DURATION
A string instance is valid if it is a valid representation according to the "duration" ABNF rule.
Definition Vocabulary.h:160
constexpr std::string_view METADATA_DESCRIPTION
An explanation about the purpose of the instance described by the schema.
Definition Vocabulary.h:327
constexpr std::string_view VALIDATION_MAX_PROPERTIES
Object validation.
Definition Vocabulary.h:289
constexpr std::string_view SCHEMA_DRAFT_2020_12
JSON Schema Draft 2020-12 URI.
Definition Vocabulary.h:44
constexpr std::string_view METADATA_TITLE
A preferably short description about the purpose of the instance described by the schema.
Definition Vocabulary.h:324
constexpr std::string_view VALIDATION_TYPE
Validation succeeds if the type of the instance matches the type represented by the given type,...
Definition Vocabulary.h:244
constexpr std::string_view METADATA_READ_ONLY
This keyword indicates that the value of the instance is managed exclusively by the owning authority,...
Definition Vocabulary.h:339