@twin.org/data-json-ld 0.0.1-next.32 → 0.0.1-next.33
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/dist/cjs/index.cjs
CHANGED
|
@@ -1942,20 +1942,22 @@ class JsonLdHelper {
|
|
|
1942
1942
|
* Validate a JSON-LD document.
|
|
1943
1943
|
* @param document The JSON-LD document to validate.
|
|
1944
1944
|
* @param validationFailures The list of validation failures to add to.
|
|
1945
|
-
* @param
|
|
1945
|
+
* @param options Optional options for validation.
|
|
1946
|
+
* @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.
|
|
1947
|
+
* @param options.validationMode The validation mode to use, defaults to either.
|
|
1946
1948
|
* @returns True if the document was valid.
|
|
1947
1949
|
*/
|
|
1948
|
-
static async validate(document, validationFailures,
|
|
1950
|
+
static async validate(document, validationFailures, options) {
|
|
1949
1951
|
if (core.Is.array(document)) {
|
|
1950
1952
|
// If the document is an array of nodes, validate each node
|
|
1951
1953
|
for (const node of document) {
|
|
1952
|
-
await JsonLdHelper.validate(node, validationFailures,
|
|
1954
|
+
await JsonLdHelper.validate(node, validationFailures, options);
|
|
1953
1955
|
}
|
|
1954
1956
|
}
|
|
1955
1957
|
else if (core.Is.array(document["@graph"])) {
|
|
1956
1958
|
// If the graph is an array of nodes, validate each node
|
|
1957
1959
|
for (const node of document["@graph"]) {
|
|
1958
|
-
await JsonLdHelper.validate(node, validationFailures,
|
|
1960
|
+
await JsonLdHelper.validate(node, validationFailures, options);
|
|
1959
1961
|
}
|
|
1960
1962
|
}
|
|
1961
1963
|
else if (core.Is.object(document)) {
|
|
@@ -1964,7 +1966,7 @@ class JsonLdHelper {
|
|
|
1964
1966
|
const expandedDoc = await JsonLdProcessor.expand(document);
|
|
1965
1967
|
const expandedDataType = core.ArrayHelper.fromObjectOrArray(expandedDoc[0]["@type"]);
|
|
1966
1968
|
if (core.Is.arrayValue(expandedDataType)) {
|
|
1967
|
-
await dataCore.DataTypeHelper.validate("document", expandedDataType[0], document, validationFailures,
|
|
1969
|
+
await dataCore.DataTypeHelper.validate("document", expandedDataType[0], document, validationFailures, options);
|
|
1968
1970
|
}
|
|
1969
1971
|
}
|
|
1970
1972
|
return validationFailures.length === 0;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1940,20 +1940,22 @@ class JsonLdHelper {
|
|
|
1940
1940
|
* Validate a JSON-LD document.
|
|
1941
1941
|
* @param document The JSON-LD document to validate.
|
|
1942
1942
|
* @param validationFailures The list of validation failures to add to.
|
|
1943
|
-
* @param
|
|
1943
|
+
* @param options Optional options for validation.
|
|
1944
|
+
* @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.
|
|
1945
|
+
* @param options.validationMode The validation mode to use, defaults to either.
|
|
1944
1946
|
* @returns True if the document was valid.
|
|
1945
1947
|
*/
|
|
1946
|
-
static async validate(document, validationFailures,
|
|
1948
|
+
static async validate(document, validationFailures, options) {
|
|
1947
1949
|
if (Is.array(document)) {
|
|
1948
1950
|
// If the document is an array of nodes, validate each node
|
|
1949
1951
|
for (const node of document) {
|
|
1950
|
-
await JsonLdHelper.validate(node, validationFailures,
|
|
1952
|
+
await JsonLdHelper.validate(node, validationFailures, options);
|
|
1951
1953
|
}
|
|
1952
1954
|
}
|
|
1953
1955
|
else if (Is.array(document["@graph"])) {
|
|
1954
1956
|
// If the graph is an array of nodes, validate each node
|
|
1955
1957
|
for (const node of document["@graph"]) {
|
|
1956
|
-
await JsonLdHelper.validate(node, validationFailures,
|
|
1958
|
+
await JsonLdHelper.validate(node, validationFailures, options);
|
|
1957
1959
|
}
|
|
1958
1960
|
}
|
|
1959
1961
|
else if (Is.object(document)) {
|
|
@@ -1962,7 +1964,7 @@ class JsonLdHelper {
|
|
|
1962
1964
|
const expandedDoc = await JsonLdProcessor.expand(document);
|
|
1963
1965
|
const expandedDataType = ArrayHelper.fromObjectOrArray(expandedDoc[0]["@type"]);
|
|
1964
1966
|
if (Is.arrayValue(expandedDataType)) {
|
|
1965
|
-
await DataTypeHelper.validate("document", expandedDataType[0], document, validationFailures,
|
|
1967
|
+
await DataTypeHelper.validate("document", expandedDataType[0], document, validationFailures, options);
|
|
1966
1968
|
}
|
|
1967
1969
|
}
|
|
1968
1970
|
return validationFailures.length === 0;
|
|
@@ -9,8 +9,13 @@ export declare class JsonLdHelper {
|
|
|
9
9
|
* Validate a JSON-LD document.
|
|
10
10
|
* @param document The JSON-LD document to validate.
|
|
11
11
|
* @param validationFailures The list of validation failures to add to.
|
|
12
|
-
* @param
|
|
12
|
+
* @param options Optional options for validation.
|
|
13
|
+
* @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.
|
|
14
|
+
* @param options.validationMode The validation mode to use, defaults to either.
|
|
13
15
|
* @returns True if the document was valid.
|
|
14
16
|
*/
|
|
15
|
-
static validate<T extends IJsonLdDocument = IJsonLdDocument>(document: T, validationFailures: IValidationFailure[],
|
|
17
|
+
static validate<T extends IJsonLdDocument = IJsonLdDocument>(document: T, validationFailures: IValidationFailure[], options?: {
|
|
18
|
+
validationMode?: ValidationMode;
|
|
19
|
+
failOnMissingType?: boolean;
|
|
20
|
+
}): Promise<boolean>;
|
|
16
21
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/data-json-ld - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.33](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.1-next.32...data-json-ld-v0.0.1-next.33) (2025-06-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add fail on missing type option and both mode ([e8b9702](https://github.com/twinfoundation/data/commit/e8b97029a04b646497ff0e55b9610291e58ae92a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/data-core bumped from 0.0.1-next.32 to 0.0.1-next.33
|
|
16
|
+
|
|
3
17
|
## [0.0.1-next.32](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.1-next.31...data-json-ld-v0.0.1-next.32) (2025-05-28)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -16,7 +16,7 @@ Class to help with JSON LD.
|
|
|
16
16
|
|
|
17
17
|
### validate()
|
|
18
18
|
|
|
19
|
-
> `static` **validate**\<`T`\>(`document`, `validationFailures`, `
|
|
19
|
+
> `static` **validate**\<`T`\>(`document`, `validationFailures`, `options?`): `Promise`\<`boolean`\>
|
|
20
20
|
|
|
21
21
|
Validate a JSON-LD document.
|
|
22
22
|
|
|
@@ -40,12 +40,22 @@ The JSON-LD document to validate.
|
|
|
40
40
|
|
|
41
41
|
The list of validation failures to add to.
|
|
42
42
|
|
|
43
|
-
#####
|
|
43
|
+
##### options?
|
|
44
|
+
|
|
45
|
+
Optional options for validation.
|
|
46
|
+
|
|
47
|
+
###### validationMode?
|
|
44
48
|
|
|
45
49
|
`ValidationMode`
|
|
46
50
|
|
|
47
51
|
The validation mode to use, defaults to either.
|
|
48
52
|
|
|
53
|
+
###### failOnMissingType?
|
|
54
|
+
|
|
55
|
+
`boolean`
|
|
56
|
+
|
|
57
|
+
If true, will fail validation if the data type is missing, defaults to false.
|
|
58
|
+
|
|
49
59
|
#### Returns
|
|
50
60
|
|
|
51
61
|
`Promise`\<`boolean`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.33",
|
|
4
4
|
"description": "Models which define the structure of JSON LD",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.1-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.1-next.33",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|