Open winston0410 opened 1 year ago
digging into this deepr myself, I realise that the issue was the main package of felte
parsed the string key into an object. To workaround this issue right now, adjusting the schema is the simplist fix
@pablo-abc just wondering is this behavior of felte
expected?
Yep, this is expected behaviour. Felte (and specially its validators) are made to handle what will eventually be a JSON payload. Dot notation is used in this case to represent nested objects. Validation in this case should be done by validating a nested object itself, not a property with a .
in its name.
Describe the bug
Validation for field with a name contains dot will fail
I notice that
@felte/validator-zod
will parse the name of field automatically, which resulted in unexpected validation result.For example, having a field called
traits.email
, I expect this is the structure of the$error
But this is what I am getting now
This make all validations fail and the form cannot be submitted.
Which package/s are you using?
felte (Svelte), @felte/validator-zod
Environment
To reproduce
Check https://github.com/winston0410/felte-zod-repo/blob/c39d253e5b6bd8db5b3e4fcc60a3213dbfac15d7/src/routes/%2Bpage.svelte#L24-L31
Small reproduction example
https://github.com/winston0410/felte-zod-repo
Screenshots
No response
Additional context
No response