Skip to content

Commit 99dcac1

Browse files
authored
docs: warning for numeric field names (#15966)
Adds warning about proper field names, specifically avoiding those th… Fixes #13534
1 parent 944a889 commit 99dcac1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

docs/fields/overview.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ export const MyField: Field = {
292292
}
293293
```
294294

295+
Since field names map directly to keys in API response objects and to column names in the database, they should follow JavaScript identifier conventions: start with a letter or underscore, and contain only letters, numbers, and underscores. Just like all Payload field names are strings, all Payload response objects use strings as their keys — so treat field names as you would a JavaScript variable name.
296+
297+
<Banner type="warning">
298+
Avoid field names that start with a digit (e.g. `'1'`, `'2field'`) or contain
299+
hyphens (e.g. `'field-name'`). While these are valid strings in TypeScript,
300+
they can cause unexpected behavior when Payload accesses data using
301+
dot-notation paths, generates GraphQL schemas, or maps fields to database
302+
columns. GraphQL identifiers do not allow hyphens, so hyphenated field names
303+
will cause schema generation to fail.
304+
</Banner>
305+
295306
Payload reserves various field names for internal use. Using reserved field names will result in your field being sanitized from the config.
296307

297308
The following field names are forbidden and cannot be used:

0 commit comments

Comments
 (0)