Unparse method #399
Unanswered
yudinmaxim
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Thank you for creating this discussion. Unfortunately, this is not supported at this time. Also, I have no idea how we could support this with a nice DX. Feel free to make suggestions. As a workaround, I would create two schemas. One for each direction. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone.
I want to do the following:
Get data from the API - perform data parsing using safeParce(schema, data) - validate and transform the data - get data with camelCase names. (This is already implemented and works well and I like it)
Create/modify form data received from the API and send the values back.
I understand how to convert data: api - valibot parse - data, but I don't understand how to do the reverse conversion: data - valibot - API.
So, I want the schema to be able to transform data not only from API - data, but also in the opposite direction.
For example, if I perform a field name transformation during data validation: field_name -> fieldName, then when performing data transfer to the API, I need to make the reverse transformation: fieldName -> field_name.
Does valibot have the ability to perform such transformations?
Beta Was this translation helpful? Give feedback.
All reactions