@postxl/schema 1.8.0 → 1.8.1

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.
@@ -448,9 +448,15 @@ function extractLabelField({ labelFieldName, ...model }, fields, ctx) {
448
448
  return zod_1.z.NEVER;
449
449
  }
450
450
  if (labelField.kind !== 'scalar' && labelField.kind !== 'id') {
451
+ const fieldType = Field.getFieldType(labelField);
452
+ const hint = labelField.kind === 'enum'
453
+ ? ` Enum fields cannot be used as label fields.`
454
+ : labelField.kind === 'relation'
455
+ ? ` Relation fields cannot be used as label fields.`
456
+ : '';
451
457
  ctx.addIssue({
452
458
  code: zod_1.z.ZodIssueCode.custom,
453
- message: `Label field ${labelFieldName} in model ${model.name} must be of type \`string\`, but instead is of type ${Field.getFieldType(labelField)}!`,
459
+ message: `Label field ${labelFieldName} in model ${model.name} must be of type \`string\`, but instead is of type \`${fieldType}\`.${hint}`,
454
460
  });
455
461
  return zod_1.z.NEVER;
456
462
  }
@@ -458,7 +464,7 @@ function extractLabelField({ labelFieldName, ...model }, fields, ctx) {
458
464
  if (type !== 'string') {
459
465
  ctx.addIssue({
460
466
  code: zod_1.z.ZodIssueCode.custom,
461
- message: `Label field ${labelFieldName} in model ${model.name} must be of type \`string\`, but instead is of type ${type}!`,
467
+ message: `Label field ${labelFieldName} in model ${model.name} must be of type \`string\`, but instead is of type \`${type}\`.`,
462
468
  });
463
469
  return zod_1.z.NEVER;
464
470
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/schema",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Decoders for PXL Schema definitions and validation for PXL code generation framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",