how object array length check array in object validation check at the same time ?
See original GitHub issueDescribe the bug how object array length check array in object validation check at the same time ?
To Reproduce
https://codesandbox.io/s/elegant-darwin-23lch
i use yup react-hook-form. but yup validation scheme only check array length. not array in object validation check don’t work my object schema under
const schema = yup
.array()
.min(1)
.max(3)
.of(
yup.object().shape({
optionName: yup
.string()
.required()
.trim()
.min(0)
.max(100),
optionPrice: yup
.number()
.required()
.min(1000)
.max(500000)
})
);
const obj = [
{ optionName: "test", optionPrice: 0 },
{ optionName: "", optionPrice: 0 }
];
await expect(schema.isValid(obj)).resolves.toBe(true);
Expected behavior A clear and concise description of what you expected to happen.
Platform (please complete the following information):
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Validation using Yup to check array length - Stack Overflow
Now I check the name is required, I need to check if myArray has length === 1 to return an error. javascript ·...
Read more >Find the length of a JavaScript object - GeeksforGeeks
Method 1: Using the Object.keys() method. The Object.keys() method is used to return the object property name as an array. The length ......
Read more >Find duplicates in an array using javaScript - Flexiple
1. We compare the index of all the items of an array with the index of the first time that number occurs. If...
Read more >How to check if an array is empty using Javascript? - Flexiple
If the length of the object is 0, then the array is considered to be empty and the function will return TRUE. Else...
Read more >JavaScript Array length Property - W3Schools
Definition and Usage. The length property sets or returns the number of elements in an array. Syntax. Return the length of an array:....
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
this will never be true, because optionPrice has a
min
set. If you don’t want validation on the items, don’t add validation to themok thank you haha i will close issue.