You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
If I use dataType: 'json' on the client, and pass the data to the server, the data only gets validated if it is a request object, not a regular object.
This schema has no problems validating. The request object contains a formData object. You can see __superform_json only gets checked using a formData object on this line.
You can see now the formData is no longer a request object, but a regular parsed object. Now, __superform_json won't get parsed at all.
Since superValidate accepts BOTH a request object and a regular object, so should the json validator. Otherwise, there is no way to modify the form data before passing it to the superValidate function. This means there are NO work arounds.
J
The text was updated successfully, but these errors were encountered:
If you transform the form data to an object, that's what will be validated, not the request. It could come from a DB or anywhere else.
It's not meant to combine FormData and the __superform_json data (which is encoded with devalue). The validation schema is for one of them, not both.
But if you want to bend the rules, you need to call superValidate twice:
// This will validate __superform_jsonconstform1=awaitsuperValidate(_formData,valibot(superFormSchema));// This will validate the transformed FormDataconstform=awaitsuperValidate(formData,valibot(formDataSchema));
Description
If I use
dataType: 'json'
on the client, and pass the data to the server, the data only gets validated if it is arequest
object, not a regular object.For example:
This schema has no problems validating. The request object contains a
formData
object. You can see__superform_json
only gets checked using aformData
object on this line.But what if I need to modify the data first?
Example:
You can see now the
formData
is no longer a request object, but a regular parsed object. Now,__superform_json
won't get parsed at all.Since
superValidate
accepts BOTH a request object and a regular object, so should thejson
validator. Otherwise, there is no way to modify the form data before passing it to thesuperValidate
function. This means there are NO work arounds.J
The text was updated successfully, but these errors were encountered: