Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  167] [ 6]  / answers: 1 / hits: 23074  / 4 Years ago, sun, may 24, 2020, 12:00:00

Most Yup examples use the shape method, but I find the documentation a little hard to understand why this is the case, and exactly what the method does.



Can someone please explain the difference between a schema defined with Yup.object({...}) and Yup.object().shape({...})?


More From » forms

 Answers
98

You can also pass a shape to the object constructor as a convenience.

yupobject documentation




Basically passing the schema to shape is just the long-form of passing it to the object constructor. Shape does however offer the benefit of chaining and overloading definitions in later chained methods. See yup.shape documentation


[#50922] Friday, May 15, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shaynelandenb

Total Points: 293
Total Questions: 97
Total Answers: 94

Location: Monaco
Member since Fri, Sep 24, 2021
3 Years ago
;