How to define the schema for an array inside the object?
See original GitHub issueHow to define the schema for an array inside the object? I wanna validate the array use string and number. the first is string type, then the second is number type. like this.
const example = {test: ["this is string type", 10]};
const test = {test: ["string", 10]};
// not working
const schema={yup.object().shape({
test: yup.array(yup.string().number()),
}}
The yup is object schema validator, it can’t array validation?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to define object in array in Mongoose schema correctly ...
You can declare trk by the following ways : - either trk : [{ lat : String, lng : String }]. or. trk...
Read more >array — Understanding JSON Schema 2020-12 documentation
A schema can ensure that each of the items in an array is unique. Simply set the uniqueItems keyword to true . {...
Read more >How to define object in array in Mongoose schema ... - Intellipaat
I'm currently having problems in creating a schema for the document below. The response from the server always returns the "trk" field values...
Read more >Mongoose v6.8.1: SchemaTypes
Mongoose supports arrays of SchemaTypes and arrays of subdocuments. Arrays of SchemaTypes are also called primitive arrays, and arrays of subdocuments are also ......
Read more >Arrays - JSON Schema
A JSON Schema for an array can be seen as set of restrictions that must apply on the elements of the array. In...
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
@Restoration The ideal way would have been
But unfortunately yup doesn’t support one-of-type yet. So the less than ideal way I could propose is
which checks type of value before evaluating it. I think this should help you.
myPropery??? on your example what is that?