Skip to content

Conversation

@zubricks
Copy link
Member

@zubricks zubricks commented Aug 26, 2025

Fixes #13534

Copy link
Member

@jacobsfletch jacobsfletch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I'm on the fence on if we really need any documentation for this at all, I left a few comments either way, but fields don't allow numeric names in the first place.

If anything, maybe we just draw a comparison between a field config and how it relates to a response object. Then provide an example of how to access it by name (similar to what you have). Basically describe Payload, not javascript.


```

That said, numeric field names are allowed but aren't recommended due to JavaScript syntax pitfalls and you should lean towards descriptive string names.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numeric field names are allowed but aren't recommended

Is this true? We enforce strings here which throws a TS error:

Screenshot 2025-08-27 at 12 23 12 PM
<Banner type="warning">
Field name values must be valid JSON object keys. Although names are always
strings, using numbers as names can break expected behavior because Payload
stores all content as nested JSON.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be worded more straight forward. Something like:

Remember: just like all Payload field names are strings, all Payload response objects use strings as their keys.

```ts
import type { Field } from 'payload'

export const NumericFieldName: Field = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading because this field's name is not numeric, it's a string as required.

@zubricks zubricks added the area: docs Improvements or additions to documentation label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Improvements or additions to documentation created-by: Payload team

3 participants