T
TanStack•2y ago
genetic-orange

Is it possible to opt out of dot notation or escape dot for field names?

I'm considering migrating a project this library but there are field names containing dots x.y but these aren't to indicate nested fields. Is there a way to opt-out of the path behavior? I do see the value in this feature but could there be a capability to escape the field names perhaps (e.g. x.y.z)? I'm happy to contribute this feature but want to understand if any interest. Other dot-notation libraries such as dottie allow passing an a string array instead of a string to pass the exact path array.
4 Replies
eastern-cyan
eastern-cyan•2y ago
The challenge I'd have is along the lines of "what happens if someone wants to have {field: {one: {"one.two.three": 123}}} then a simple opt-out wouldn't work More than happy to have a PR that introduces this but I think the syntax I'd prefer is:
name="field.one['one.two.three']"
name="field.one['one.two.three']"
Or something similar
genetic-orange
genetic-orangeOP•2y ago
Thoughts on accepting an array like name={['field','one','one.two.three']} ? The issue with name="field.one['one.two.three']" is that the behavior for root key is not very obvious, unless the first key can also be using the brackets. E.g. name="['one.two.three']" On thinking on this more, this isn't all that bad, so I'm inclined to do go ahead with this too if that looks okay to you. Sounds like it's ok to go ahead with a PR. I'll get something going.
eastern-cyan
eastern-cyan•2y ago
I'm conflicted on which one we should go for. Thinking more the array seems like it'd be better to type in TS, even if I like the look of the API less But yup, feel free to make a PR 🙂

Did you find this page helpful?