@hestia-earth/data-validation 0.41.15 → 0.41.16
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.d.mts +1 -1
- package/file-errors/public-api.d.ts +1 -1
- package/file-errors/public-api.js +22 -0
- package/file-errors/public-api.mjs +22 -0
- package/index.js +5 -0
- package/index.mjs +5 -0
- package/package.json +1 -1
- package/validation.json +5 -0
|
@@ -57,7 +57,7 @@ declare const urlConfig: (baseUrl?: string) => IUrlConfig;
|
|
|
57
57
|
* primary entry point). They are kept structurally compatible on purpose.
|
|
58
58
|
*/
|
|
59
59
|
type validationErrorLevel = 'error' | 'warning';
|
|
60
|
-
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta' | 'newlyCovered' | 'recommended' | 'missing';
|
|
60
|
+
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta' | 'newlyCovered' | 'recommended' | 'missing' | 'cause' | 'compound';
|
|
61
61
|
type validationErrorKeyword = 'required' | 'type' | 'if' | 'then' | 'not';
|
|
62
62
|
interface ICustomValidationRules {
|
|
63
63
|
const?: any;
|
|
@@ -57,7 +57,7 @@ declare const urlConfig: (baseUrl?: string) => IUrlConfig;
|
|
|
57
57
|
* primary entry point). They are kept structurally compatible on purpose.
|
|
58
58
|
*/
|
|
59
59
|
type validationErrorLevel = 'error' | 'warning';
|
|
60
|
-
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta' | 'newlyCovered' | 'recommended' | 'missing';
|
|
60
|
+
type validationErrorParam = 'missingProperty' | 'type' | 'term' | 'termType' | 'termIds' | 'model' | 'product' | 'range' | 'node' | 'allowedValues' | 'allowedValue' | 'additionalProperty' | 'expected' | 'default' | 'current' | 'percentage' | 'keys' | 'threshold' | 'outliers' | 'country' | 'min' | 'max' | 'mu' | 'sd' | 'defaultSource' | 'source' | 'group' | 'message' | 'distance' | 'siteType' | 'products' | 'units' | 'duplicatedIndexes' | 'invalidCoordinates' | 'ids' | 'limit' | 'delta' | 'newlyCovered' | 'recommended' | 'missing' | 'cause' | 'compound';
|
|
61
61
|
type validationErrorKeyword = 'required' | 'type' | 'if' | 'then' | 'not';
|
|
62
62
|
interface ICustomValidationRules {
|
|
63
63
|
const?: any;
|
|
@@ -632,6 +632,11 @@ var validations = [
|
|
|
632
632
|
level: "warning",
|
|
633
633
|
message: "should add missing inputs"
|
|
634
634
|
},
|
|
635
|
+
{
|
|
636
|
+
function: "validate_compound_fertiliser_composition",
|
|
637
|
+
level: "warning",
|
|
638
|
+
message: "should match the nutrient ratio of the compound fertiliser"
|
|
639
|
+
},
|
|
635
640
|
{
|
|
636
641
|
function: "validate_related_impacts",
|
|
637
642
|
level: "error",
|
|
@@ -2294,6 +2299,23 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2294
2299
|
"must equal to endDate - startDate in decimal years": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in years (~${expected})`,
|
|
2295
2300
|
"must be more than or equal to other crop residues": ({ params: { expected } }) => `Must be more than or equal to sum(${expected.join(" + ")})`,
|
|
2296
2301
|
"should add missing inputs": ({ params: { expected } }) => `Should add missing inputs: ${listAsCode(expected)}`,
|
|
2302
|
+
"should match the nutrient ratio of the compound fertiliser": ({ params }) => {
|
|
2303
|
+
var _a, _b;
|
|
2304
|
+
const [denominator, numerator] = ((_a = params == null ? void 0 : params.termIds) != null ? _a : []).map((id) => termLink({ id }));
|
|
2305
|
+
const expected = (params == null ? void 0 : params.min) === (params == null ? void 0 : params.max) ? code(params == null ? void 0 : params.min) : `${code(params == null ? void 0 : params.min)} to ${code(params == null ? void 0 : params.max)}`;
|
|
2306
|
+
const causes = {
|
|
2307
|
+
swapped: "This is close to the inverse of the expected ratio: the values of the two Inputs may have been swapped.",
|
|
2308
|
+
elemental: `This is close to the expected ratio converted to elements: the value may have been given as kg of elemental P or K rather than kg of ${code(
|
|
2309
|
+
"P2O5"
|
|
2310
|
+
)} or ${code("K2O")}.`,
|
|
2311
|
+
otherCompound: `This is close to the ratio of ${termLink({
|
|
2312
|
+
id: params == null ? void 0 : params.compound
|
|
2313
|
+
})}: the values may have been calculated from the composition of another fertiliser.`
|
|
2314
|
+
};
|
|
2315
|
+
return `The value of ${numerator} divided by the value of ${denominator} is ${code(params == null ? void 0 : params.current)}, but the composition of this fertiliser gives a ratio of ${expected}.
|
|
2316
|
+
${(_b = causes[params == null ? void 0 : params.cause]) != null ? _b : ""}
|
|
2317
|
+
Please check that both Inputs are the amounts of each nutrient applied with this fertiliser.`;
|
|
2318
|
+
},
|
|
2297
2319
|
"the property value type is incorrect": ({ params: { expected } }) => `The value must be a ${expected}.`,
|
|
2298
2320
|
"the node value type is incorrect": ({ params: { expected } }) => `The value must be a ${expected}.`,
|
|
2299
2321
|
"can not be linked to the same type": ({ params: { current } }) => `Cannot be linked to the same ${current}.`,
|
|
@@ -630,6 +630,11 @@ var validations = [
|
|
|
630
630
|
level: "warning",
|
|
631
631
|
message: "should add missing inputs"
|
|
632
632
|
},
|
|
633
|
+
{
|
|
634
|
+
function: "validate_compound_fertiliser_composition",
|
|
635
|
+
level: "warning",
|
|
636
|
+
message: "should match the nutrient ratio of the compound fertiliser"
|
|
637
|
+
},
|
|
633
638
|
{
|
|
634
639
|
function: "validate_related_impacts",
|
|
635
640
|
level: "error",
|
|
@@ -2292,6 +2297,23 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
|
|
|
2292
2297
|
"must equal to endDate - startDate in decimal years": ({ params: { expected } }) => `Must be equal to ${code("endDate")} - ${code("startDate")} in years (~${expected})`,
|
|
2293
2298
|
"must be more than or equal to other crop residues": ({ params: { expected } }) => `Must be more than or equal to sum(${expected.join(" + ")})`,
|
|
2294
2299
|
"should add missing inputs": ({ params: { expected } }) => `Should add missing inputs: ${listAsCode(expected)}`,
|
|
2300
|
+
"should match the nutrient ratio of the compound fertiliser": ({ params }) => {
|
|
2301
|
+
var _a, _b;
|
|
2302
|
+
const [denominator, numerator] = ((_a = params == null ? void 0 : params.termIds) != null ? _a : []).map((id) => termLink({ id }));
|
|
2303
|
+
const expected = (params == null ? void 0 : params.min) === (params == null ? void 0 : params.max) ? code(params == null ? void 0 : params.min) : `${code(params == null ? void 0 : params.min)} to ${code(params == null ? void 0 : params.max)}`;
|
|
2304
|
+
const causes = {
|
|
2305
|
+
swapped: "This is close to the inverse of the expected ratio: the values of the two Inputs may have been swapped.",
|
|
2306
|
+
elemental: `This is close to the expected ratio converted to elements: the value may have been given as kg of elemental P or K rather than kg of ${code(
|
|
2307
|
+
"P2O5"
|
|
2308
|
+
)} or ${code("K2O")}.`,
|
|
2309
|
+
otherCompound: `This is close to the ratio of ${termLink({
|
|
2310
|
+
id: params == null ? void 0 : params.compound
|
|
2311
|
+
})}: the values may have been calculated from the composition of another fertiliser.`
|
|
2312
|
+
};
|
|
2313
|
+
return `The value of ${numerator} divided by the value of ${denominator} is ${code(params == null ? void 0 : params.current)}, but the composition of this fertiliser gives a ratio of ${expected}.
|
|
2314
|
+
${(_b = causes[params == null ? void 0 : params.cause]) != null ? _b : ""}
|
|
2315
|
+
Please check that both Inputs are the amounts of each nutrient applied with this fertiliser.`;
|
|
2316
|
+
},
|
|
2295
2317
|
"the property value type is incorrect": ({ params: { expected } }) => `The value must be a ${expected}.`,
|
|
2296
2318
|
"the node value type is incorrect": ({ params: { expected } }) => `The value must be a ${expected}.`,
|
|
2297
2319
|
"can not be linked to the same type": ({ params: { current } }) => `Cannot be linked to the same ${current}.`,
|
package/index.js
CHANGED
|
@@ -638,6 +638,11 @@ var validations = [
|
|
|
638
638
|
level: "warning",
|
|
639
639
|
message: "should add missing inputs"
|
|
640
640
|
},
|
|
641
|
+
{
|
|
642
|
+
function: "validate_compound_fertiliser_composition",
|
|
643
|
+
level: "warning",
|
|
644
|
+
message: "should match the nutrient ratio of the compound fertiliser"
|
|
645
|
+
},
|
|
641
646
|
{
|
|
642
647
|
function: "validate_related_impacts",
|
|
643
648
|
level: "error",
|
package/index.mjs
CHANGED
|
@@ -636,6 +636,11 @@ var validations = [
|
|
|
636
636
|
level: "warning",
|
|
637
637
|
message: "should add missing inputs"
|
|
638
638
|
},
|
|
639
|
+
{
|
|
640
|
+
function: "validate_compound_fertiliser_composition",
|
|
641
|
+
level: "warning",
|
|
642
|
+
message: "should match the nutrient ratio of the compound fertiliser"
|
|
643
|
+
},
|
|
639
644
|
{
|
|
640
645
|
function: "validate_related_impacts",
|
|
641
646
|
level: "error",
|
package/package.json
CHANGED
package/validation.json
CHANGED
|
@@ -625,6 +625,11 @@
|
|
|
625
625
|
"level": "warning",
|
|
626
626
|
"message": "should add missing inputs"
|
|
627
627
|
},
|
|
628
|
+
{
|
|
629
|
+
"function": "validate_compound_fertiliser_composition",
|
|
630
|
+
"level": "warning",
|
|
631
|
+
"message": "should match the nutrient ratio of the compound fertiliser"
|
|
632
|
+
},
|
|
628
633
|
{
|
|
629
634
|
"function": "validate_related_impacts",
|
|
630
635
|
"level": "error",
|