@hestia-earth/data-validation 0.41.8 → 0.41.10
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 +35 -0
- package/file-errors/public-api.mjs +35 -0
- package/index.js +15 -0
- package/index.mjs +15 -0
- package/package.json +4 -4
- package/validation.json +15 -0
|
@@ -432,6 +432,11 @@ var validations = [
|
|
|
432
432
|
level: "warning",
|
|
433
433
|
message: "should specify the fate of cropResidue"
|
|
434
434
|
},
|
|
435
|
+
{
|
|
436
|
+
function: "validate_cycleDuration",
|
|
437
|
+
level: "error",
|
|
438
|
+
message: "must be one year prior to endDate"
|
|
439
|
+
},
|
|
435
440
|
{
|
|
436
441
|
function: "validate_cycleDuration",
|
|
437
442
|
level: "error",
|
|
@@ -662,6 +667,11 @@ var validations = [
|
|
|
662
667
|
level: "error",
|
|
663
668
|
message: "must be a product"
|
|
664
669
|
},
|
|
670
|
+
{
|
|
671
|
+
function: "validate_input_unspecified_term",
|
|
672
|
+
level: "warning",
|
|
673
|
+
message: "should use a specific term"
|
|
674
|
+
},
|
|
665
675
|
{
|
|
666
676
|
function: "_validate_all_values",
|
|
667
677
|
level: "warning",
|
|
@@ -771,6 +781,11 @@ var validations = [
|
|
|
771
781
|
function: "validate_excreta_inputs_products",
|
|
772
782
|
level: "error",
|
|
773
783
|
message: "must be included as an Input"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
function: "validate_transformation_inputs_value",
|
|
787
|
+
level: "error",
|
|
788
|
+
message: "must be specified for multiple Inputs with the same term"
|
|
774
789
|
}
|
|
775
790
|
];
|
|
776
791
|
|
|
@@ -1476,6 +1491,13 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1476
1491
|
},
|
|
1477
1492
|
"must be equal to previous product multiplied by the share": () => `Products from a transformation which are an Input in to the next transformation must follow the following rule:
|
|
1478
1493
|
${code("previous.product.value * current.transformedShare / 100 == current.input.value")}`,
|
|
1494
|
+
"must be specified for multiple Inputs with the same term": ({ params }) => {
|
|
1495
|
+
var _a, _b;
|
|
1496
|
+
return `There are multiple Inputs of ${code(((_a = params == null ? void 0 : params.term) == null ? void 0 : _a.name) || ((_b = params == null ? void 0 : params.term) == null ? void 0 : _b["@id"]))} in this Transformation
|
|
1497
|
+
which only differ by fields other than ${code("variety")} or ${code("fate")}, so the ${code("transformedShare")}
|
|
1498
|
+
cannot tell how the Product ${code("value")} should be split between them.
|
|
1499
|
+
Please specify the ${code("value")} of each of these Inputs.`;
|
|
1500
|
+
},
|
|
1479
1501
|
"at least one Input must be a Product of the Cycle": () => `A Transformation converts a Product from a Cycle into another Product.
|
|
1480
1502
|
Therefore, at least one Input into the Transformation must be a Product of the Cycle.`,
|
|
1481
1503
|
"must have only one entry with the same term.termType = excretaManagement": () => `There can only be one Practice of type excretaManagement in a Cycle.
|
|
@@ -1523,6 +1545,15 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1523
1545
|
(_d = params == null ? void 0 : params.term) == null ? void 0 : _d.termType
|
|
1524
1546
|
)} which reflects the specific ${glossaryTypeLink((_e = params == null ? void 0 : params.product) == null ? void 0 : _e.termType)}.`;
|
|
1525
1547
|
},
|
|
1548
|
+
"should use a specific term": ({ params }) => {
|
|
1549
|
+
var _a, _b, _c;
|
|
1550
|
+
return `You have used ${termLink({
|
|
1551
|
+
id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"],
|
|
1552
|
+
name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name
|
|
1553
|
+
})}, which does not say what was used.
|
|
1554
|
+
If you know it, choose the specific ${glossaryTypeLink((_c = params == null ? void 0 : params.term) == null ? void 0 : _c.termType)} term instead:
|
|
1555
|
+
background emissions, characterisation factors and completeness all depend on it.`;
|
|
1556
|
+
},
|
|
1526
1557
|
"should not use several terms describing the same product": ({ params }) => {
|
|
1527
1558
|
var _a, _b, _c, _d;
|
|
1528
1559
|
const isFertiliser = ((_a = params == null ? void 0 : params.term) == null ? void 0 : _a.termType) === schema.TermTermType.organicFertiliser;
|
|
@@ -2141,6 +2172,10 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2141
2172
|
"must be in the same format as endDate": () => `The date format does not match the format of ${code("endDate")}. You must use the same date format for both fields.`,
|
|
2142
2173
|
"must be at least equal to the minimum value": ({ params: { min } }) => `Must be at least equal to ${min}`,
|
|
2143
2174
|
"must equal to endDate - startDate in days": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in days (inclusive of the ${code("startDate")} and ${code("endDate")} days) (~${expected})`,
|
|
2175
|
+
"must be one year prior to endDate": ({ params: { current, expected } }) => `With a ${schemaLink("Cycle#startDateDefinition", "startDateDefinition")} of ${code("one year prior")}, the ${code(
|
|
2176
|
+
"startDate"
|
|
2177
|
+
)} must be the day after the ${code("endDate")} one year earlier, so that the Cycle covers exactly one year.
|
|
2178
|
+
Your ${code("startDate")} is ${code(current)}; it should be ${code(expected)}.`,
|
|
2144
2179
|
"must equal to endDate - startDate in decimal years": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in years (~${expected})`,
|
|
2145
2180
|
"must be more than or equal to other crop residues": ({ params: { expected } }) => `Must be more than or equal to sum(${expected.join(" + ")})`,
|
|
2146
2181
|
"should add missing inputs": ({ params: { expected } }) => `Should add missing inputs: ${listAsCode(expected)}`,
|
|
@@ -430,6 +430,11 @@ var validations = [
|
|
|
430
430
|
level: "warning",
|
|
431
431
|
message: "should specify the fate of cropResidue"
|
|
432
432
|
},
|
|
433
|
+
{
|
|
434
|
+
function: "validate_cycleDuration",
|
|
435
|
+
level: "error",
|
|
436
|
+
message: "must be one year prior to endDate"
|
|
437
|
+
},
|
|
433
438
|
{
|
|
434
439
|
function: "validate_cycleDuration",
|
|
435
440
|
level: "error",
|
|
@@ -660,6 +665,11 @@ var validations = [
|
|
|
660
665
|
level: "error",
|
|
661
666
|
message: "must be a product"
|
|
662
667
|
},
|
|
668
|
+
{
|
|
669
|
+
function: "validate_input_unspecified_term",
|
|
670
|
+
level: "warning",
|
|
671
|
+
message: "should use a specific term"
|
|
672
|
+
},
|
|
663
673
|
{
|
|
664
674
|
function: "_validate_all_values",
|
|
665
675
|
level: "warning",
|
|
@@ -769,6 +779,11 @@ var validations = [
|
|
|
769
779
|
function: "validate_excreta_inputs_products",
|
|
770
780
|
level: "error",
|
|
771
781
|
message: "must be included as an Input"
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
function: "validate_transformation_inputs_value",
|
|
785
|
+
level: "error",
|
|
786
|
+
message: "must be specified for multiple Inputs with the same term"
|
|
772
787
|
}
|
|
773
788
|
];
|
|
774
789
|
|
|
@@ -1474,6 +1489,13 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1474
1489
|
},
|
|
1475
1490
|
"must be equal to previous product multiplied by the share": () => `Products from a transformation which are an Input in to the next transformation must follow the following rule:
|
|
1476
1491
|
${code("previous.product.value * current.transformedShare / 100 == current.input.value")}`,
|
|
1492
|
+
"must be specified for multiple Inputs with the same term": ({ params }) => {
|
|
1493
|
+
var _a, _b;
|
|
1494
|
+
return `There are multiple Inputs of ${code(((_a = params == null ? void 0 : params.term) == null ? void 0 : _a.name) || ((_b = params == null ? void 0 : params.term) == null ? void 0 : _b["@id"]))} in this Transformation
|
|
1495
|
+
which only differ by fields other than ${code("variety")} or ${code("fate")}, so the ${code("transformedShare")}
|
|
1496
|
+
cannot tell how the Product ${code("value")} should be split between them.
|
|
1497
|
+
Please specify the ${code("value")} of each of these Inputs.`;
|
|
1498
|
+
},
|
|
1477
1499
|
"at least one Input must be a Product of the Cycle": () => `A Transformation converts a Product from a Cycle into another Product.
|
|
1478
1500
|
Therefore, at least one Input into the Transformation must be a Product of the Cycle.`,
|
|
1479
1501
|
"must have only one entry with the same term.termType = excretaManagement": () => `There can only be one Practice of type excretaManagement in a Cycle.
|
|
@@ -1521,6 +1543,15 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
1521
1543
|
(_d = params == null ? void 0 : params.term) == null ? void 0 : _d.termType
|
|
1522
1544
|
)} which reflects the specific ${glossaryTypeLink((_e = params == null ? void 0 : params.product) == null ? void 0 : _e.termType)}.`;
|
|
1523
1545
|
},
|
|
1546
|
+
"should use a specific term": ({ params }) => {
|
|
1547
|
+
var _a, _b, _c;
|
|
1548
|
+
return `You have used ${termLink({
|
|
1549
|
+
id: (_a = params == null ? void 0 : params.term) == null ? void 0 : _a["@id"],
|
|
1550
|
+
name: (_b = params == null ? void 0 : params.term) == null ? void 0 : _b.name
|
|
1551
|
+
})}, which does not say what was used.
|
|
1552
|
+
If you know it, choose the specific ${glossaryTypeLink((_c = params == null ? void 0 : params.term) == null ? void 0 : _c.termType)} term instead:
|
|
1553
|
+
background emissions, characterisation factors and completeness all depend on it.`;
|
|
1554
|
+
},
|
|
1524
1555
|
"should not use several terms describing the same product": ({ params }) => {
|
|
1525
1556
|
var _a, _b, _c, _d;
|
|
1526
1557
|
const isFertiliser = ((_a = params == null ? void 0 : params.term) == null ? void 0 : _a.termType) === TermTermType.organicFertiliser;
|
|
@@ -2139,6 +2170,10 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2139
2170
|
"must be in the same format as endDate": () => `The date format does not match the format of ${code("endDate")}. You must use the same date format for both fields.`,
|
|
2140
2171
|
"must be at least equal to the minimum value": ({ params: { min } }) => `Must be at least equal to ${min}`,
|
|
2141
2172
|
"must equal to endDate - startDate in days": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in days (inclusive of the ${code("startDate")} and ${code("endDate")} days) (~${expected})`,
|
|
2173
|
+
"must be one year prior to endDate": ({ params: { current, expected } }) => `With a ${schemaLink("Cycle#startDateDefinition", "startDateDefinition")} of ${code("one year prior")}, the ${code(
|
|
2174
|
+
"startDate"
|
|
2175
|
+
)} must be the day after the ${code("endDate")} one year earlier, so that the Cycle covers exactly one year.
|
|
2176
|
+
Your ${code("startDate")} is ${code(current)}; it should be ${code(expected)}.`,
|
|
2142
2177
|
"must equal to endDate - startDate in decimal years": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in years (~${expected})`,
|
|
2143
2178
|
"must be more than or equal to other crop residues": ({ params: { expected } }) => `Must be more than or equal to sum(${expected.join(" + ")})`,
|
|
2144
2179
|
"should add missing inputs": ({ params: { expected } }) => `Should add missing inputs: ${listAsCode(expected)}`,
|
package/index.js
CHANGED
|
@@ -438,6 +438,11 @@ var validations = [
|
|
|
438
438
|
level: "warning",
|
|
439
439
|
message: "should specify the fate of cropResidue"
|
|
440
440
|
},
|
|
441
|
+
{
|
|
442
|
+
function: "validate_cycleDuration",
|
|
443
|
+
level: "error",
|
|
444
|
+
message: "must be one year prior to endDate"
|
|
445
|
+
},
|
|
441
446
|
{
|
|
442
447
|
function: "validate_cycleDuration",
|
|
443
448
|
level: "error",
|
|
@@ -668,6 +673,11 @@ var validations = [
|
|
|
668
673
|
level: "error",
|
|
669
674
|
message: "must be a product"
|
|
670
675
|
},
|
|
676
|
+
{
|
|
677
|
+
function: "validate_input_unspecified_term",
|
|
678
|
+
level: "warning",
|
|
679
|
+
message: "should use a specific term"
|
|
680
|
+
},
|
|
671
681
|
{
|
|
672
682
|
function: "_validate_all_values",
|
|
673
683
|
level: "warning",
|
|
@@ -777,6 +787,11 @@ var validations = [
|
|
|
777
787
|
function: "validate_excreta_inputs_products",
|
|
778
788
|
level: "error",
|
|
779
789
|
message: "must be included as an Input"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
function: "validate_transformation_inputs_value",
|
|
793
|
+
level: "error",
|
|
794
|
+
message: "must be specified for multiple Inputs with the same term"
|
|
780
795
|
}
|
|
781
796
|
];
|
|
782
797
|
var validation_default = {
|
package/index.mjs
CHANGED
|
@@ -436,6 +436,11 @@ var validations = [
|
|
|
436
436
|
level: "warning",
|
|
437
437
|
message: "should specify the fate of cropResidue"
|
|
438
438
|
},
|
|
439
|
+
{
|
|
440
|
+
function: "validate_cycleDuration",
|
|
441
|
+
level: "error",
|
|
442
|
+
message: "must be one year prior to endDate"
|
|
443
|
+
},
|
|
439
444
|
{
|
|
440
445
|
function: "validate_cycleDuration",
|
|
441
446
|
level: "error",
|
|
@@ -666,6 +671,11 @@ var validations = [
|
|
|
666
671
|
level: "error",
|
|
667
672
|
message: "must be a product"
|
|
668
673
|
},
|
|
674
|
+
{
|
|
675
|
+
function: "validate_input_unspecified_term",
|
|
676
|
+
level: "warning",
|
|
677
|
+
message: "should use a specific term"
|
|
678
|
+
},
|
|
669
679
|
{
|
|
670
680
|
function: "_validate_all_values",
|
|
671
681
|
level: "warning",
|
|
@@ -775,6 +785,11 @@ var validations = [
|
|
|
775
785
|
function: "validate_excreta_inputs_products",
|
|
776
786
|
level: "error",
|
|
777
787
|
message: "must be included as an Input"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
function: "validate_transformation_inputs_value",
|
|
791
|
+
level: "error",
|
|
792
|
+
message: "must be specified for multiple Inputs with the same term"
|
|
778
793
|
}
|
|
779
794
|
];
|
|
780
795
|
var validation_default = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hestia-earth/data-validation",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.10",
|
|
4
4
|
"description": "HESTIA Data Validation library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"@commitlint/cli": "^17.8.1",
|
|
80
80
|
"@commitlint/config-conventional": "^17.8.1",
|
|
81
81
|
"@hestia-earth/eslint-config": "^0.1.1",
|
|
82
|
-
"@hestia-earth/json-schema": "^39.0
|
|
83
|
-
"@hestia-earth/schema": "^39.0
|
|
84
|
-
"@hestia-earth/schema-validation": "^39.0
|
|
82
|
+
"@hestia-earth/json-schema": "^39.2.0",
|
|
83
|
+
"@hestia-earth/schema": "^39.2.0",
|
|
84
|
+
"@hestia-earth/schema-validation": "^39.2.0",
|
|
85
85
|
"@hestia-earth/utils": "^0.17.17",
|
|
86
86
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
87
87
|
"@typescript-eslint/parser": "^5.62.0",
|
package/validation.json
CHANGED
|
@@ -425,6 +425,11 @@
|
|
|
425
425
|
"level": "warning",
|
|
426
426
|
"message": "should specify the fate of cropResidue"
|
|
427
427
|
},
|
|
428
|
+
{
|
|
429
|
+
"function": "validate_cycleDuration",
|
|
430
|
+
"level": "error",
|
|
431
|
+
"message": "must be one year prior to endDate"
|
|
432
|
+
},
|
|
428
433
|
{
|
|
429
434
|
"function": "validate_cycleDuration",
|
|
430
435
|
"level": "error",
|
|
@@ -655,6 +660,11 @@
|
|
|
655
660
|
"level": "error",
|
|
656
661
|
"message": "must be a product"
|
|
657
662
|
},
|
|
663
|
+
{
|
|
664
|
+
"function": "validate_input_unspecified_term",
|
|
665
|
+
"level": "warning",
|
|
666
|
+
"message": "should use a specific term"
|
|
667
|
+
},
|
|
658
668
|
{
|
|
659
669
|
"function": "_validate_all_values",
|
|
660
670
|
"level": "warning",
|
|
@@ -764,6 +774,11 @@
|
|
|
764
774
|
"function": "validate_excreta_inputs_products",
|
|
765
775
|
"level": "error",
|
|
766
776
|
"message": "must be included as an Input"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"function": "validate_transformation_inputs_value",
|
|
780
|
+
"level": "error",
|
|
781
|
+
"message": "must be specified for multiple Inputs with the same term"
|
|
767
782
|
}
|
|
768
783
|
]
|
|
769
784
|
}
|