a have object like this
const foo = {
person: {
name:"Jon",
sex:"men"
},
job: "drinker"
};
When i use console.log(foo.person.name)
l got undefined. And can’t validate my object
Question: how i can validate foo.person.name.
a have object like this
const foo = {
person: {
name:"Jon",
sex:"men"
},
job: "drinker"
};
When i use console.log(foo.person.name)
l got undefined. And can’t validate my object
Question: how i can validate foo.person.name.
2
Answers
You can use optional chaining and pre check if the value exists or not.
Yup is a schema builder for runtime value parsing and validation.
So defining the correct datatype is very crucial. In your case you are trying to define a object, so you can try something like:
If you need further help with this you can go through Yup Readme on npm