@hestia-earth/data-validation 0.41.13 → 0.41.14

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.
@@ -187,6 +187,11 @@ var validations = [
187
187
  level: "error",
188
188
  message: "must not have background methodTier"
189
189
  },
190
+ {
191
+ function: "validate_methodTier_background",
192
+ level: "error",
193
+ message: "must be an existing term"
194
+ },
190
195
  {
191
196
  function: "validate_depth",
192
197
  level: "warning",
@@ -1660,6 +1665,13 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
1660
1665
  100
1661
1666
  )} if the Number of tillages has been set to ${code(0)}. Please resolve this conflict.`,
1662
1667
  "can not be linked to the same Cycle": () => "You can not link an Input to the Impact Assessment of the same Cycle.",
1668
+ "can not be linked to a different term": ({ params }) => {
1669
+ var _a;
1670
+ return `The Impact Assessment linked to this Input is for the Product ${termLink({
1671
+ id: params == null ? void 0 : params.current
1672
+ })}, which does not match the Input.
1673
+ Link an Impact Assessment whose Product is ${joinWithOr(((_a = params == null ? void 0 : params.expected) != null ? _a : []).map((id) => termLink({ id })))} instead.`;
1674
+ },
1663
1675
  // deprecated, remove when message is not being used anymore
1664
1676
  "must be 0 for product value 0": ({ dataPath, params }, errorCount) => `If the amount produced is zero, the ${code(dataPath == null ? void 0 : dataPath.split(".").pop())} of ${errorCount === 1 ? code(params == null ? void 0 : params.term.name) : "that product"} must also be zero.`,
1665
1677
  "economicValueShare must be 0 for product value 0": ({ params }, errorCount) => `If the amount produced is zero, the economicValueShare of ${errorCount === 1 ? code(params == null ? void 0 : params.term.name) : "that product"} must also be zero.`,
@@ -2117,13 +2129,15 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2117
2129
  return `If completeness is set to true for ${schemaLink(
2118
2130
  `Completeness#${params.expected}`,
2119
2131
  params.expected
2120
- )}, every Transport must have a ${schemaLink("Transport#value", "value")} (in tkm) or a ${schemaLink(
2132
+ )}, every Transport must have a ${schemaLink("Transport#value", "value")} (in tkm), a ${schemaLink(
2121
2133
  "Transport#distance",
2122
2134
  "distance"
2123
- )} (in km). This ${termLink({
2135
+ )} (in km), or ${schemaLink("Transport#inputs", "inputs")} (e.g. the fuel used) which all have a ${code(
2136
+ "value"
2137
+ )}. This ${termLink({
2124
2138
  id: (_a = params.term) == null ? void 0 : _a["@id"],
2125
2139
  name: (_b = params.term) == null ? void 0 : _b.name
2126
- })} has neither.`;
2140
+ })} has none of these.`;
2127
2141
  },
2128
2142
  "primary product cannot be an input": ({ params }) => params.siteType === schema.SiteSiteType["agri-food processor"] ? `For a processing cycle, the primary Product must not also be an Input into the cycle.
2129
2143
  This ensures we reflect the full process rather than just single sub-processes.
@@ -2160,11 +2174,11 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2160
2174
  "Saplings"
2161
2175
  )} used divided by the number of possible Cycles in the plantation's lifespan.
2162
2176
  See the ${guideLink("guide-file-upload-special-cases", "special upload case")} for more details.`,
2163
- "seed cannot be used as an input here": ({ params }) => `The Cycle only represents plantation crops, which are established from saplings rather than sown, so ${externalNodeLink(
2177
+ "seed cannot be used as an input here": ({ params }) => `The Cycle only represents plantation crops, which are established from planting material rather than sown, so ${externalNodeLink(
2164
2178
  {
2165
2179
  "@type": schema.NodeType.Term,
2166
2180
  "@id": String(params.expected),
2167
- name: "Saplings, depreciated amount per Cycle"
2181
+ name: humanizeTermId(String(params.expected))
2168
2182
  }
2169
2183
  )} should be used instead of ${code(params.current)}.
2170
2184
  If this is a case of intercropping, add the relevant ${code(schema.TermTermType.landCover)} Practices to the Cycle, or, if it was sown as a cover crop under the plantation, add the ${termLink(
@@ -2175,7 +2189,7 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2175
2189
  )} Practice.`,
2176
2190
  "saplingsDepreciatedAmountPerCycle cannot be used as an input here": ({ params }) => `The Cycle only represents non-plantation crops, so ${termLink({
2177
2191
  id: String(params.expected),
2178
- name: "Seed"
2192
+ name: humanizeTermId(String(params.expected))
2179
2193
  })} should be used instead of ${code(params.current)}.
2180
2194
  If this is a case of intercropping, add the relevant ${code(schema.TermTermType.landCover)} Practices to the Cycle.`,
2181
2195
  "must use the depreciated term": ({ params }) => {
@@ -2253,11 +2267,22 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2253
2267
  Please amend the value of ${code("harvestedArea")} accordingly.`,
2254
2268
  "must be above the minimum": ({ params: { min } }) => `Must be above ${min}.`,
2255
2269
  "must be below the maximum": ({ params: { max } }) => `Must be below ${max}.`,
2270
+ "must be greater than min": ({ params }) => `The ${code("max")} (${joinValues([].concat(params == null ? void 0 : params.max).map(String))}) must be greater than the ${code(
2271
+ "min"
2272
+ )} (${joinValues([].concat(params == null ? void 0 : params.min).map(String))}).
2273
+ Please check they have not been swapped: the ${code("value")} can be gap-filled from them.`,
2256
2274
  "must be linked to waste input": () => `The term ${code(
2257
2275
  "ionisingCompoundsToAirInputsProduction"
2258
2276
  )} can only have 1 entry of ${code("termType")}: ${glossaryTypeLink(
2259
2277
  schema.TermTermType.waste
2260
2278
  )}, so that the ${code("value")} field can represent the amount of units of that waste term.`,
2279
+ "must be an existing term": ({ params }) => {
2280
+ var _a, _b;
2281
+ return `${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"]))} is not in the ${glossaryLink(
2282
+ "Glossary"
2283
+ )}: it has been removed or renamed.
2284
+ Please replace it with the current term.`;
2285
+ },
2261
2286
  "must not have background methodTier": ({ params: { allowedValues } }) => `Only background emissions (e.g., "Inputs Production") can have ${code("methodTier")}=${schema.EmissionMethodTier.background}.
2262
2287
  You must instead choose one of the following values: ${listAsCode(allowedValues)}`,
2263
2288
  "should be within acceptable range of the lookup value": ({ params }) => `The ${code(params.term["@id"])} value is ${code(params.delta)}% higher than our default value for this Term (${code(params.expected)}).
@@ -185,6 +185,11 @@ var validations = [
185
185
  level: "error",
186
186
  message: "must not have background methodTier"
187
187
  },
188
+ {
189
+ function: "validate_methodTier_background",
190
+ level: "error",
191
+ message: "must be an existing term"
192
+ },
188
193
  {
189
194
  function: "validate_depth",
190
195
  level: "warning",
@@ -1658,6 +1663,13 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
1658
1663
  100
1659
1664
  )} if the Number of tillages has been set to ${code(0)}. Please resolve this conflict.`,
1660
1665
  "can not be linked to the same Cycle": () => "You can not link an Input to the Impact Assessment of the same Cycle.",
1666
+ "can not be linked to a different term": ({ params }) => {
1667
+ var _a;
1668
+ return `The Impact Assessment linked to this Input is for the Product ${termLink({
1669
+ id: params == null ? void 0 : params.current
1670
+ })}, which does not match the Input.
1671
+ Link an Impact Assessment whose Product is ${joinWithOr(((_a = params == null ? void 0 : params.expected) != null ? _a : []).map((id) => termLink({ id })))} instead.`;
1672
+ },
1661
1673
  // deprecated, remove when message is not being used anymore
1662
1674
  "must be 0 for product value 0": ({ dataPath, params }, errorCount) => `If the amount produced is zero, the ${code(dataPath == null ? void 0 : dataPath.split(".").pop())} of ${errorCount === 1 ? code(params == null ? void 0 : params.term.name) : "that product"} must also be zero.`,
1663
1675
  "economicValueShare must be 0 for product value 0": ({ params }, errorCount) => `If the amount produced is zero, the economicValueShare of ${errorCount === 1 ? code(params == null ? void 0 : params.term.name) : "that product"} must also be zero.`,
@@ -2115,13 +2127,15 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2115
2127
  return `If completeness is set to true for ${schemaLink(
2116
2128
  `Completeness#${params.expected}`,
2117
2129
  params.expected
2118
- )}, every Transport must have a ${schemaLink("Transport#value", "value")} (in tkm) or a ${schemaLink(
2130
+ )}, every Transport must have a ${schemaLink("Transport#value", "value")} (in tkm), a ${schemaLink(
2119
2131
  "Transport#distance",
2120
2132
  "distance"
2121
- )} (in km). This ${termLink({
2133
+ )} (in km), or ${schemaLink("Transport#inputs", "inputs")} (e.g. the fuel used) which all have a ${code(
2134
+ "value"
2135
+ )}. This ${termLink({
2122
2136
  id: (_a = params.term) == null ? void 0 : _a["@id"],
2123
2137
  name: (_b = params.term) == null ? void 0 : _b.name
2124
- })} has neither.`;
2138
+ })} has none of these.`;
2125
2139
  },
2126
2140
  "primary product cannot be an input": ({ params }) => params.siteType === SiteSiteType["agri-food processor"] ? `For a processing cycle, the primary Product must not also be an Input into the cycle.
2127
2141
  This ensures we reflect the full process rather than just single sub-processes.
@@ -2158,11 +2172,11 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2158
2172
  "Saplings"
2159
2173
  )} used divided by the number of possible Cycles in the plantation's lifespan.
2160
2174
  See the ${guideLink("guide-file-upload-special-cases", "special upload case")} for more details.`,
2161
- "seed cannot be used as an input here": ({ params }) => `The Cycle only represents plantation crops, which are established from saplings rather than sown, so ${externalNodeLink(
2175
+ "seed cannot be used as an input here": ({ params }) => `The Cycle only represents plantation crops, which are established from planting material rather than sown, so ${externalNodeLink(
2162
2176
  {
2163
2177
  "@type": NodeType.Term,
2164
2178
  "@id": String(params.expected),
2165
- name: "Saplings, depreciated amount per Cycle"
2179
+ name: humanizeTermId(String(params.expected))
2166
2180
  }
2167
2181
  )} should be used instead of ${code(params.current)}.
2168
2182
  If this is a case of intercropping, add the relevant ${code(TermTermType.landCover)} Practices to the Cycle, or, if it was sown as a cover crop under the plantation, add the ${termLink(
@@ -2173,7 +2187,7 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2173
2187
  )} Practice.`,
2174
2188
  "saplingsDepreciatedAmountPerCycle cannot be used as an input here": ({ params }) => `The Cycle only represents non-plantation crops, so ${termLink({
2175
2189
  id: String(params.expected),
2176
- name: "Seed"
2190
+ name: humanizeTermId(String(params.expected))
2177
2191
  })} should be used instead of ${code(params.current)}.
2178
2192
  If this is a case of intercropping, add the relevant ${code(TermTermType.landCover)} Practices to the Cycle.`,
2179
2193
  "must use the depreciated term": ({ params }) => {
@@ -2251,11 +2265,22 @@ var createErrorFormatter = ({ renderer: r, urls }) => {
2251
2265
  Please amend the value of ${code("harvestedArea")} accordingly.`,
2252
2266
  "must be above the minimum": ({ params: { min } }) => `Must be above ${min}.`,
2253
2267
  "must be below the maximum": ({ params: { max } }) => `Must be below ${max}.`,
2268
+ "must be greater than min": ({ params }) => `The ${code("max")} (${joinValues([].concat(params == null ? void 0 : params.max).map(String))}) must be greater than the ${code(
2269
+ "min"
2270
+ )} (${joinValues([].concat(params == null ? void 0 : params.min).map(String))}).
2271
+ Please check they have not been swapped: the ${code("value")} can be gap-filled from them.`,
2254
2272
  "must be linked to waste input": () => `The term ${code(
2255
2273
  "ionisingCompoundsToAirInputsProduction"
2256
2274
  )} can only have 1 entry of ${code("termType")}: ${glossaryTypeLink(
2257
2275
  TermTermType.waste
2258
2276
  )}, so that the ${code("value")} field can represent the amount of units of that waste term.`,
2277
+ "must be an existing term": ({ params }) => {
2278
+ var _a, _b;
2279
+ return `${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"]))} is not in the ${glossaryLink(
2280
+ "Glossary"
2281
+ )}: it has been removed or renamed.
2282
+ Please replace it with the current term.`;
2283
+ },
2259
2284
  "must not have background methodTier": ({ params: { allowedValues } }) => `Only background emissions (e.g., "Inputs Production") can have ${code("methodTier")}=${EmissionMethodTier.background}.
2260
2285
  You must instead choose one of the following values: ${listAsCode(allowedValues)}`,
2261
2286
  "should be within acceptable range of the lookup value": ({ params }) => `The ${code(params.term["@id"])} value is ${code(params.delta)}% higher than our default value for this Term (${code(params.expected)}).
package/index.js CHANGED
@@ -193,6 +193,11 @@ var validations = [
193
193
  level: "error",
194
194
  message: "must not have background methodTier"
195
195
  },
196
+ {
197
+ function: "validate_methodTier_background",
198
+ level: "error",
199
+ message: "must be an existing term"
200
+ },
196
201
  {
197
202
  function: "validate_depth",
198
203
  level: "warning",
package/index.mjs CHANGED
@@ -191,6 +191,11 @@ var validations = [
191
191
  level: "error",
192
192
  message: "must not have background methodTier"
193
193
  },
194
+ {
195
+ function: "validate_methodTier_background",
196
+ level: "error",
197
+ message: "must be an existing term"
198
+ },
194
199
  {
195
200
  function: "validate_depth",
196
201
  level: "warning",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/data-validation",
3
- "version": "0.41.13",
3
+ "version": "0.41.14",
4
4
  "description": "HESTIA Data Validation library",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
package/validation.json CHANGED
@@ -180,6 +180,11 @@
180
180
  "level": "error",
181
181
  "message": "must not have background methodTier"
182
182
  },
183
+ {
184
+ "function": "validate_methodTier_background",
185
+ "level": "error",
186
+ "message": "must be an existing term"
187
+ },
183
188
  {
184
189
  "function": "validate_depth",
185
190
  "level": "warning",