@adminiumjs/manifest 0.3.43 → 0.3.44

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.
@@ -338,12 +338,16 @@ const agreeTargetSchema = z.union([
338
338
  * A value of the row that must agree with another: `column` (followed along
339
339
  * `path` through foreign keys) equals, is at most, or is at least the target.
340
340
  * `when` applies it only to rows whose value (along its own `path`) is one of
341
- * `in`.
341
+ * `in`. `length: true` compares how many characters a text value has, with
342
+ * `lte` alone: a line's lettering no longer than its product allows
343
+ * (`{ "column": "lettering", "length": true, "lte": { "via": "product_id",
344
+ * "column": "lettering_limit" } }`), refused as `too-long`.
342
345
  */
343
346
  export const agreeSchema = z
344
347
  .object({
345
348
  column: refSchema,
346
349
  path: pathSchema.optional(),
350
+ length: z.literal(true).optional(),
347
351
  when: z.object({ path: pathSchema.optional(), in: z.array(scalarSchema).min(1).max(32) }).strict().optional(),
348
352
  eq: agreeTargetSchema.optional(),
349
353
  lte: agreeTargetSchema.optional(),
@@ -2023,9 +2027,21 @@ function agreeIssues(index, table, parent, agree, at) {
2023
2027
  out.push({ path: at(test, 'column'), message: `"${via.references}" has no column "${target.column}"` });
2024
2028
  }
2025
2029
  }
2026
- else if (typeof reached !== 'string' && !agreeValueFits(reached.column, target.value)) {
2030
+ else if (agree.length !== true && typeof reached !== 'string' && !agreeValueFits(reached.column, target.value)) {
2027
2031
  out.push({ path: at(test, 'value'), message: `${JSON.stringify(target.value)} is not a value of "${reached.table}.${reached.column.ref}"` });
2028
2032
  }
2033
+ if (agree.length === true) {
2034
+ // How many characters a text has, at most a number: the text is the row's, the most is a number.
2035
+ if (test !== 'lte')
2036
+ out.push({ path: at(test), message: 'a length is compared with lte (at most so many characters)' });
2037
+ if (typeof reached !== 'string' && reached.column.type !== 'text')
2038
+ out.push({ path: at('length'), message: `"${reached.table}.${reached.column.ref}" is not text, so it has no length` });
2039
+ if (other !== undefined && !NUMBERS.includes(other.type))
2040
+ out.push({ path: at(test), message: `"${other.ref}" is not a number, so it is no most characters` });
2041
+ if ('value' in target && (typeof target.value !== 'number' || !Number.isInteger(target.value) || target.value < 0))
2042
+ out.push({ path: at(test, 'value'), message: 'the most characters is a whole number' });
2043
+ return out;
2044
+ }
2029
2045
  if (typeof reached !== 'string') {
2030
2046
  if (test !== 'eq' && !NUMBERS.includes(reached.column.type)) {
2031
2047
  out.push({ path: at(test), message: `"${reached.table}.${reached.column.ref}" is not a number, so it is not at most or at least another` });