validation fails if the id of the field is given as json path Ex: groups['Basic'].parameters[0].name.value
See original GitHub issueHi
Am using formik as my form library, where am giving the id of the input element is given a json path Ex: “groups[‘Basic’].parameters[0].name.value”
where form values will be generated as below:
"values": {
"groups": {
"basic": {
"parameters": [
{
"domain": {
"value": "2"
}
} ] }
Same id is set to while creating the yup validation schema. But yup always trying get the value from form values assuming id is plain string key in form values object.
https://github.com/jquense/yup/blob/dd474ff79fb34aee5780dc0aebeac42eb6b88e48/src/object.js#L158
I think should support something like below.
if (field.validate) return field.validate(_.get(value, key), innerOptions);
Currently is there any other way or workaround to achieve the same for now?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Resolve the "Parameter validation failed" error in AWS ...
1. Open the AWS CloudFormation console. · 2. In the navigation pane, choose Stacks. · 3. Form the Stack name column, choose the...
Read more >Validate, Query, and Change JSON Data with Built-in Functions
The following query will return the documents where the id JSON field matches the value AndersenFamily , ordered by city and state JSON...
Read more >Understanding JSON Schema
The names of the basic types in JavaScript and JSON can be ... That means that validation will fail if, for example, a...
Read more >Working with Json fields (Concepts) - Prisma
Use the Json Prisma field type to read, write, and perform basic filtering on JSON types in the underlying database. In the following...
Read more >12: 9.15. JSON Functions and Operators - PostgreSQL
text, json or jsonb, Get JSON object field by key ... jsonb, Are the left JSON path/value entries contained at the top level...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
you need to define schema’s at each level like:
Just came into the issue too. This solution works fine except that we don’t use lodash internally. Here’s the plain JS way for future people coming into this issue (found it via Google so…)
Assuming we have such a payload where the key is dynamically created:
The following schema would allow us to make use of i.e. Formik nested objects support while keepin Yup to validate our inputs.