When using Yup version 1.3.3, there is a change in behavior compared to version 0.32.11 when validating JSON strings with array and object schemas. #2167
this must be a array type, but the final value was: `"[{\"param1\":\"val1\",\"param2\":\"val2\"}]"`
Expected Behavior:
The validation should work as it did in version 0.32.11, allowing the automatic parsing of JSON strings when validating against array and object schemas.
Similar Issue with Object Schema:
In addition to the reported issue with array schemas, the same behavior is observed when using object schemas. Here's an example:
correct there is a change in behavior json is not automatically parsed anymore, you can use json() method now . Please see the changelogs and guides for migrating
Code that worked in Yup 0.32.11:
Error with Yup 1.3.3:
this must be a
array
type, but the final value was: `"[{\"param1\":\"val1\",\"param2\":\"val2\"}]"`Expected Behavior:
The validation should work as it did in version 0.32.11, allowing the automatic parsing of JSON strings when validating against array and object schemas.
Similar Issue with Object Schema:
In addition to the reported issue with array schemas, the same behavior is observed when using object schemas. Here's an example:
Error with Yup 1.3.3:
this must be an
object
type, but the final value was: `"{"param1": "val1", "param2": "val2"}"`Expected Behavior:
The validation for object schemas should also work as expected, allowing automatic parsing of JSON strings.