Skip to content

Commit

Permalink
fix(api-headless-cms): update reserved field ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Jul 23, 2024
1 parent fb1a87e commit 5d0f987
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions packages/api-headless-cms/src/crud/contentModel/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,38 @@ import camelCase from "lodash/camelCase";

const fieldSystemFields: string[] = [
"id",
"fieldId",
"storageId",
"label",
"helpText",
"placeholderText",
"type",
"multipleValues",
"predefinedValues",
"renderer",
"validation",
"listValidation",
"settings"
"entryId",
"createdOn",
"modifiedOn",
"publishedOn",
"savedOn",
"deletedOn",
"restoredOn",
"firstPublishedOn",
"lastPublishedOn",
"createdBy",
"modifiedBy",
"savedBy",
"deletedBy",
"restoredBy",
"firstPublishedBy",
"lastPublishedBy",
"revisionCreatedOn",
"revisionModifiedOn",
"revisionSavedOn",
"revisionDeletedOn",
"revisionRestoredOn",
"revisionFirstPublishedOn",
"revisionLastPublishedOn",
"revisionCreatedBy",
"revisionModifiedBy",
"revisionSavedBy",
"revisionDeletedBy",
"revisionRestoredBy",
"revisionFirstPublishedBy",
"revisionLastPublishedBy",
"meta",
"wbyAco_location"
];

const str = zod.string().trim();
Expand Down Expand Up @@ -43,8 +63,7 @@ const fieldSchema = zod.object({
if (fieldSystemFields.includes(value)) {
return ctx.addIssue({
code: zod.ZodIssueCode.custom,
message: `Provided ${value} is not valid - "${value}" is an auto-generated field.`,
path: ["fieldId"]
message: `Field ID "${value}" is a reserved keyword, and is not allowed.`
});
}
}),
Expand Down

0 comments on commit 5d0f987

Please sign in to comment.