@hestia-earth/data-validation 0.41.14 → 0.41.15
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/file-errors/public-api.js +53 -16
- package/file-errors/public-api.mjs +53 -16
- package/index.js +10 -0
- package/index.mjs +10 -0
- package/package.json +1 -1
- package/validation.json +10 -0
|
@@ -297,6 +297,11 @@ var validations = [
|
|
|
297
297
|
level: "error",
|
|
298
298
|
message: "at least one landCover practice must match an equivalent product"
|
|
299
299
|
},
|
|
300
|
+
{
|
|
301
|
+
function: "validate_coverCrop_landCover_primary_product",
|
|
302
|
+
level: "error",
|
|
303
|
+
message: "a cover crop can not be the land cover of the primary product"
|
|
304
|
+
},
|
|
300
305
|
{
|
|
301
306
|
function: "validate_practices_management",
|
|
302
307
|
level: "error",
|
|
@@ -327,6 +332,11 @@ var validations = [
|
|
|
327
332
|
level: "error",
|
|
328
333
|
message: "is outside the allowed range"
|
|
329
334
|
},
|
|
335
|
+
{
|
|
336
|
+
function: "validate_soilTexture_depths",
|
|
337
|
+
level: "warning",
|
|
338
|
+
message: "should be given at the same depths as the soil content"
|
|
339
|
+
},
|
|
330
340
|
{
|
|
331
341
|
function: "validate_depths",
|
|
332
342
|
level: "error",
|
|
@@ -1433,6 +1443,25 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1433
1443
|
At least one measurement of sand, silt, or clay content does not match the possible range for the specified soil texture.`}
|
|
1434
1444
|
${errorCount === 1 ? "Please check the measurement, its depth intervals, and the dates of the measurement or update the soil texture if needed." : "Please check your measurements, their depth intervals, and the dates of the measurements or update the soil textures if needed."}`;
|
|
1435
1445
|
},
|
|
1446
|
+
"should be given at the same depths as the soil content": ({ params }) => {
|
|
1447
|
+
var _a, _b, _c;
|
|
1448
|
+
const formatDepths = (depths) => {
|
|
1449
|
+
var _a2, _b2;
|
|
1450
|
+
return `${(_a2 = depths == null ? void 0 : depths.depthUpper) != null ? _a2 : "-"}-${(_b2 = depths == null ? void 0 : depths.depthLower) != null ? _b2 : "-"} cm`;
|
|
1451
|
+
};
|
|
1452
|
+
return `The soil texture ${termLink({
|
|
1453
|
+
id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"],
|
|
1454
|
+
name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name
|
|
1455
|
+
})} is given at ${code(
|
|
1456
|
+
formatDepths(params == null ? void 0 : params.current)
|
|
1457
|
+
)}, but the sand, silt and clay content are only given at ${joinValues(
|
|
1458
|
+
((_c = params == null ? void 0 : params.expected) != null ? _c : []).map(formatDepths)
|
|
1459
|
+
)}.
|
|
1460
|
+
The soil texture is only checked against the sand, silt and clay content measured at the same ${code(
|
|
1461
|
+
"depthUpper"
|
|
1462
|
+
)} and ${code("depthLower")}, so at this depth the two are never compared.
|
|
1463
|
+
Please add the sand, silt and clay content at the same depths as the soil texture.`;
|
|
1464
|
+
},
|
|
1436
1465
|
"should be equal to one of the allowed values": ({ params, dataPath, schemaPath }, count, errors) => {
|
|
1437
1466
|
var _a, _b;
|
|
1438
1467
|
const paths = parseDataPath(dataPath);
|
|
@@ -1940,26 +1969,29 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1940
1969
|
schema.TermTermType.liveAnimal
|
|
1941
1970
|
)} to the ${schemaLink("Cycle#animals", "Animal")} blank nodes.
|
|
1942
1971
|
The allowed product ids are: ${listAsCode(params == null ? void 0 : params.expected)}`,
|
|
1943
|
-
"duration must be in specified interval": ({ params: { term } = {} }) =>
|
|
1944
|
-
|
|
1945
|
-
"
|
|
1946
|
-
"
|
|
1947
|
-
|
|
1972
|
+
"duration must be in specified interval": ({ dataPath, params: { term } = {} }) => {
|
|
1973
|
+
const node = /\.practices\[\d+\]$/.test(dataPath != null ? dataPath : "") ? "Practice" : "Management";
|
|
1974
|
+
return ["shortFallow", "shortBareFallow"].includes(term["@id"]) ? `${code("Short fallow")} is defined as land left fallow for less than 365 days.
|
|
1975
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1976
|
+
`${node}#endDate`,
|
|
1977
|
+
"endDate"
|
|
1978
|
+
)} on this term and ensure the difference between the two dates is less than 365 days.
|
|
1948
1979
|
If it is more than 365 days, consider using the terms ${code("Long fallow")} or ${code("Set aside")} instead.` : ["longFallow", "longBareFallow"].includes(term["@id"]) ? `${code("Long fallow")} is defined as land left fallow for more than a year but less than five years.
|
|
1949
|
-
Please check the ${schemaLink(
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1980
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1981
|
+
`${node}#endDate`,
|
|
1982
|
+
"endDate"
|
|
1983
|
+
)} on this term and ensure the difference between the two dates falls between 365 and 1826 days.
|
|
1953
1984
|
If it is less than 365 days, consider using the term ${code("Short fallow")} instead.
|
|
1954
1985
|
If it is more than 1826 days, consider using the term ${code("Set aside")} instead.` : `${code(
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
Please check the ${schemaLink(
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1986
|
+
"Set aside"
|
|
1987
|
+
)} is defined as the temporary set aside of land for more than five years but less than twenty years.
|
|
1988
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1989
|
+
`${node}#endDate`,
|
|
1990
|
+
"endDate"
|
|
1991
|
+
)} on this term and ensure the difference between the two dates falls between 1826 and 7305 days.
|
|
1961
1992
|
If it is less than 1826 days, consider using the terms ${code("Short fallow")}or ${code("Long fallow")} instead.
|
|
1962
|
-
If it is more than 7305 days, consider using the term ${code("Other natural vegetation")} instead
|
|
1993
|
+
If it is more than 7305 days, consider using the term ${code("Other natural vegetation")} instead.`;
|
|
1994
|
+
},
|
|
1963
1995
|
"must not add the feed input to the Cycle as well": ({ params: { term } = {} }) => `You have added the animal feed Input ${code(term["@id"])} to the Cycle inputs as well, which might lead to double counting.
|
|
1964
1996
|
If you do not know the amount of ${code(term["@id"])} given to each Animal, please add the Input to the Cycle only.`,
|
|
1965
1997
|
"must provide value or min and max": ({ params }) => {
|
|
@@ -2160,6 +2192,11 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2160
2192
|
`If specifying fallow periods, you must also include the Product's equivalent Practice with a ${code("startDate")} and ${code("endDate")}.`,
|
|
2161
2193
|
`Alternatively, do not set these ${code(schema.TermTermType.landCover)} practices, and they will be gap filled automatically from products.`
|
|
2162
2194
|
])}`,
|
|
2195
|
+
"a cover crop can not be the land cover of the primary product": ({ params }) => {
|
|
2196
|
+
var _a, _b, _c, _d;
|
|
2197
|
+
return `The ${termLink({ id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"], name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name })} Practice is set as a cover crop, but it is the land cover of ${termLink({ id: (_c = params == null ? void 0 : params.product) == null ? void 0 : _c["@id"], name: (_d = params == null ? void 0 : params.product) == null ? void 0 : _d.name })}, the primary Product of this Cycle. HESTIA counts the land cover of a cover crop separately from the main crop, so this land cover would be counted twice.
|
|
2198
|
+
Remove the cover crop property from this Practice, and add the cover crop as its own ${code(schema.TermTermType.landCover)} Practice if it is known.`;
|
|
2199
|
+
},
|
|
2163
2200
|
"should match the site management node value": ({ params }) => `The data you have uploaded in the Management node are not consistent with the data provided in the Cycles.
|
|
2164
2201
|
${typeof (params == null ? void 0 : params.current) === "boolean" ? `A ${code("Management")} node must have the same ${code("value")} as every Practice using the same ${code("term")} between the same ${code("startDate")} and ${code("endDate")} \u2014 your Cycles say ${code(params == null ? void 0 : params.current)}, but the ${code("Management")} node has ${code(params == null ? void 0 : params.expected)}.` : `The ${code("value")} of a ${code("Management")} node must be the total of every Practice using the same ${code("term")} between the same ${code("startDate")} and ${code("endDate")} \u2014 your Cycles add up to ${code(params == null ? void 0 : params.current)}, but the ${code("Management")} node has ${code(params == null ? void 0 : params.expected)}.`}
|
|
2165
2202
|
Please check your upload and ensure that the data is consistent throughout.`,
|
|
@@ -295,6 +295,11 @@ var validations = [
|
|
|
295
295
|
level: "error",
|
|
296
296
|
message: "at least one landCover practice must match an equivalent product"
|
|
297
297
|
},
|
|
298
|
+
{
|
|
299
|
+
function: "validate_coverCrop_landCover_primary_product",
|
|
300
|
+
level: "error",
|
|
301
|
+
message: "a cover crop can not be the land cover of the primary product"
|
|
302
|
+
},
|
|
298
303
|
{
|
|
299
304
|
function: "validate_practices_management",
|
|
300
305
|
level: "error",
|
|
@@ -325,6 +330,11 @@ var validations = [
|
|
|
325
330
|
level: "error",
|
|
326
331
|
message: "is outside the allowed range"
|
|
327
332
|
},
|
|
333
|
+
{
|
|
334
|
+
function: "validate_soilTexture_depths",
|
|
335
|
+
level: "warning",
|
|
336
|
+
message: "should be given at the same depths as the soil content"
|
|
337
|
+
},
|
|
328
338
|
{
|
|
329
339
|
function: "validate_depths",
|
|
330
340
|
level: "error",
|
|
@@ -1431,6 +1441,25 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1431
1441
|
At least one measurement of sand, silt, or clay content does not match the possible range for the specified soil texture.`}
|
|
1432
1442
|
${errorCount === 1 ? "Please check the measurement, its depth intervals, and the dates of the measurement or update the soil texture if needed." : "Please check your measurements, their depth intervals, and the dates of the measurements or update the soil textures if needed."}`;
|
|
1433
1443
|
},
|
|
1444
|
+
"should be given at the same depths as the soil content": ({ params }) => {
|
|
1445
|
+
var _a, _b, _c;
|
|
1446
|
+
const formatDepths = (depths) => {
|
|
1447
|
+
var _a2, _b2;
|
|
1448
|
+
return `${(_a2 = depths == null ? void 0 : depths.depthUpper) != null ? _a2 : "-"}-${(_b2 = depths == null ? void 0 : depths.depthLower) != null ? _b2 : "-"} cm`;
|
|
1449
|
+
};
|
|
1450
|
+
return `The soil texture ${termLink({
|
|
1451
|
+
id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"],
|
|
1452
|
+
name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name
|
|
1453
|
+
})} is given at ${code(
|
|
1454
|
+
formatDepths(params == null ? void 0 : params.current)
|
|
1455
|
+
)}, but the sand, silt and clay content are only given at ${joinValues(
|
|
1456
|
+
((_c = params == null ? void 0 : params.expected) != null ? _c : []).map(formatDepths)
|
|
1457
|
+
)}.
|
|
1458
|
+
The soil texture is only checked against the sand, silt and clay content measured at the same ${code(
|
|
1459
|
+
"depthUpper"
|
|
1460
|
+
)} and ${code("depthLower")}, so at this depth the two are never compared.
|
|
1461
|
+
Please add the sand, silt and clay content at the same depths as the soil texture.`;
|
|
1462
|
+
},
|
|
1434
1463
|
"should be equal to one of the allowed values": ({ params, dataPath, schemaPath }, count, errors) => {
|
|
1435
1464
|
var _a, _b;
|
|
1436
1465
|
const paths = parseDataPath(dataPath);
|
|
@@ -1938,26 +1967,29 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1938
1967
|
TermTermType.liveAnimal
|
|
1939
1968
|
)} to the ${schemaLink("Cycle#animals", "Animal")} blank nodes.
|
|
1940
1969
|
The allowed product ids are: ${listAsCode(params == null ? void 0 : params.expected)}`,
|
|
1941
|
-
"duration must be in specified interval": ({ params: { term } = {} }) =>
|
|
1942
|
-
|
|
1943
|
-
"
|
|
1944
|
-
"
|
|
1945
|
-
|
|
1970
|
+
"duration must be in specified interval": ({ dataPath, params: { term } = {} }) => {
|
|
1971
|
+
const node = /\.practices\[\d+\]$/.test(dataPath != null ? dataPath : "") ? "Practice" : "Management";
|
|
1972
|
+
return ["shortFallow", "shortBareFallow"].includes(term["@id"]) ? `${code("Short fallow")} is defined as land left fallow for less than 365 days.
|
|
1973
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1974
|
+
`${node}#endDate`,
|
|
1975
|
+
"endDate"
|
|
1976
|
+
)} on this term and ensure the difference between the two dates is less than 365 days.
|
|
1946
1977
|
If it is more than 365 days, consider using the terms ${code("Long fallow")} or ${code("Set aside")} instead.` : ["longFallow", "longBareFallow"].includes(term["@id"]) ? `${code("Long fallow")} is defined as land left fallow for more than a year but less than five years.
|
|
1947
|
-
Please check the ${schemaLink(
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1978
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1979
|
+
`${node}#endDate`,
|
|
1980
|
+
"endDate"
|
|
1981
|
+
)} on this term and ensure the difference between the two dates falls between 365 and 1826 days.
|
|
1951
1982
|
If it is less than 365 days, consider using the term ${code("Short fallow")} instead.
|
|
1952
1983
|
If it is more than 1826 days, consider using the term ${code("Set aside")} instead.` : `${code(
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
Please check the ${schemaLink(
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1984
|
+
"Set aside"
|
|
1985
|
+
)} is defined as the temporary set aside of land for more than five years but less than twenty years.
|
|
1986
|
+
Please check the ${schemaLink(`${node}#startDate`, "startDate")} and ${schemaLink(
|
|
1987
|
+
`${node}#endDate`,
|
|
1988
|
+
"endDate"
|
|
1989
|
+
)} on this term and ensure the difference between the two dates falls between 1826 and 7305 days.
|
|
1959
1990
|
If it is less than 1826 days, consider using the terms ${code("Short fallow")}or ${code("Long fallow")} instead.
|
|
1960
|
-
If it is more than 7305 days, consider using the term ${code("Other natural vegetation")} instead
|
|
1991
|
+
If it is more than 7305 days, consider using the term ${code("Other natural vegetation")} instead.`;
|
|
1992
|
+
},
|
|
1961
1993
|
"must not add the feed input to the Cycle as well": ({ params: { term } = {} }) => `You have added the animal feed Input ${code(term["@id"])} to the Cycle inputs as well, which might lead to double counting.
|
|
1962
1994
|
If you do not know the amount of ${code(term["@id"])} given to each Animal, please add the Input to the Cycle only.`,
|
|
1963
1995
|
"must provide value or min and max": ({ params }) => {
|
|
@@ -2158,6 +2190,11 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2158
2190
|
`If specifying fallow periods, you must also include the Product's equivalent Practice with a ${code("startDate")} and ${code("endDate")}.`,
|
|
2159
2191
|
`Alternatively, do not set these ${code(TermTermType.landCover)} practices, and they will be gap filled automatically from products.`
|
|
2160
2192
|
])}`,
|
|
2193
|
+
"a cover crop can not be the land cover of the primary product": ({ params }) => {
|
|
2194
|
+
var _a, _b, _c, _d;
|
|
2195
|
+
return `The ${termLink({ id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"], name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name })} Practice is set as a cover crop, but it is the land cover of ${termLink({ id: (_c = params == null ? void 0 : params.product) == null ? void 0 : _c["@id"], name: (_d = params == null ? void 0 : params.product) == null ? void 0 : _d.name })}, the primary Product of this Cycle. HESTIA counts the land cover of a cover crop separately from the main crop, so this land cover would be counted twice.
|
|
2196
|
+
Remove the cover crop property from this Practice, and add the cover crop as its own ${code(TermTermType.landCover)} Practice if it is known.`;
|
|
2197
|
+
},
|
|
2161
2198
|
"should match the site management node value": ({ params }) => `The data you have uploaded in the Management node are not consistent with the data provided in the Cycles.
|
|
2162
2199
|
${typeof (params == null ? void 0 : params.current) === "boolean" ? `A ${code("Management")} node must have the same ${code("value")} as every Practice using the same ${code("term")} between the same ${code("startDate")} and ${code("endDate")} \u2014 your Cycles say ${code(params == null ? void 0 : params.current)}, but the ${code("Management")} node has ${code(params == null ? void 0 : params.expected)}.` : `The ${code("value")} of a ${code("Management")} node must be the total of every Practice using the same ${code("term")} between the same ${code("startDate")} and ${code("endDate")} \u2014 your Cycles add up to ${code(params == null ? void 0 : params.current)}, but the ${code("Management")} node has ${code(params == null ? void 0 : params.expected)}.`}
|
|
2163
2200
|
Please check your upload and ensure that the data is consistent throughout.`,
|
package/index.js
CHANGED
|
@@ -303,6 +303,11 @@ var validations = [
|
|
|
303
303
|
level: "error",
|
|
304
304
|
message: "at least one landCover practice must match an equivalent product"
|
|
305
305
|
},
|
|
306
|
+
{
|
|
307
|
+
function: "validate_coverCrop_landCover_primary_product",
|
|
308
|
+
level: "error",
|
|
309
|
+
message: "a cover crop can not be the land cover of the primary product"
|
|
310
|
+
},
|
|
306
311
|
{
|
|
307
312
|
function: "validate_practices_management",
|
|
308
313
|
level: "error",
|
|
@@ -333,6 +338,11 @@ var validations = [
|
|
|
333
338
|
level: "error",
|
|
334
339
|
message: "is outside the allowed range"
|
|
335
340
|
},
|
|
341
|
+
{
|
|
342
|
+
function: "validate_soilTexture_depths",
|
|
343
|
+
level: "warning",
|
|
344
|
+
message: "should be given at the same depths as the soil content"
|
|
345
|
+
},
|
|
336
346
|
{
|
|
337
347
|
function: "validate_depths",
|
|
338
348
|
level: "error",
|
package/index.mjs
CHANGED
|
@@ -301,6 +301,11 @@ var validations = [
|
|
|
301
301
|
level: "error",
|
|
302
302
|
message: "at least one landCover practice must match an equivalent product"
|
|
303
303
|
},
|
|
304
|
+
{
|
|
305
|
+
function: "validate_coverCrop_landCover_primary_product",
|
|
306
|
+
level: "error",
|
|
307
|
+
message: "a cover crop can not be the land cover of the primary product"
|
|
308
|
+
},
|
|
304
309
|
{
|
|
305
310
|
function: "validate_practices_management",
|
|
306
311
|
level: "error",
|
|
@@ -331,6 +336,11 @@ var validations = [
|
|
|
331
336
|
level: "error",
|
|
332
337
|
message: "is outside the allowed range"
|
|
333
338
|
},
|
|
339
|
+
{
|
|
340
|
+
function: "validate_soilTexture_depths",
|
|
341
|
+
level: "warning",
|
|
342
|
+
message: "should be given at the same depths as the soil content"
|
|
343
|
+
},
|
|
334
344
|
{
|
|
335
345
|
function: "validate_depths",
|
|
336
346
|
level: "error",
|
package/package.json
CHANGED
package/validation.json
CHANGED
|
@@ -290,6 +290,11 @@
|
|
|
290
290
|
"level": "error",
|
|
291
291
|
"message": "at least one landCover practice must match an equivalent product"
|
|
292
292
|
},
|
|
293
|
+
{
|
|
294
|
+
"function": "validate_coverCrop_landCover_primary_product",
|
|
295
|
+
"level": "error",
|
|
296
|
+
"message": "a cover crop can not be the land cover of the primary product"
|
|
297
|
+
},
|
|
293
298
|
{
|
|
294
299
|
"function": "validate_practices_management",
|
|
295
300
|
"level": "error",
|
|
@@ -320,6 +325,11 @@
|
|
|
320
325
|
"level": "error",
|
|
321
326
|
"message": "is outside the allowed range"
|
|
322
327
|
},
|
|
328
|
+
{
|
|
329
|
+
"function": "validate_soilTexture_depths",
|
|
330
|
+
"level": "warning",
|
|
331
|
+
"message": "should be given at the same depths as the soil content"
|
|
332
|
+
},
|
|
323
333
|
{
|
|
324
334
|
"function": "validate_depths",
|
|
325
335
|
"level": "error",
|