Skip to content

Commit 173db34

Browse files
Ashu96adrians5j
authored andcommitted
fix(api-headless-cms): trim fieldId before save
1 parent 5e7ee98 commit 173db34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/api-headless-cms/src/content/plugins/models/ContentModel/createFieldsModel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { validation } from "@webiny/validation";
2-
import { withFields, string, object, setOnce, boolean, fields } from "@webiny/commodo";
2+
import { withFields, string, object, setOnce, onSet, boolean, fields, pipe } from "@webiny/commodo";
33
import { i18nField } from "@webiny/api-headless-cms/content/plugins/modelFields/i18nFields";
44
import { any } from "@webiny/api-headless-cms/content/plugins/models/anyField";
55
import idValidation from "./idValidation";
@@ -14,7 +14,10 @@ export default context => {
1414

1515
return withFields({
1616
_id: setOnce()(string({ validation: requiredShortString })),
17-
fieldId: setOnce()(string({ validation: idValidation })),
17+
fieldId: pipe(
18+
onSet(value => value && value.trim()),
19+
setOnce()
20+
)(string({ validation: idValidation })),
1821
label: i18nField({
1922
field: string({ validation: requiredShortString }),
2023
context

0 commit comments

Comments
 (0)