Allow null doesn't work on array and object
See original GitHub issueHi,
I’m not sure if you guys are aware of this issue/bug.
Joi:
name: Joi.string().allow(null).required
TypeScript:
name: string | null
This result is correct. However, when I use it with the array type, it doesn’t generate | null
Joi:
imageUrls: Joi.array().items(Joi.string()).allow(null).required()
TypeScript:
imageUrls: string[]
It’s supposed to be imageUrls: string[] | null
The same issue with object.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
JOI :allow null values in array - Stack Overflow
If you want to allow the array to be null use: Joi.array().items(Joi.string()).allow(null);. If you want to allow null or whitespace strings inside the ......
Read more >Array of Array of nulls or nulls? · Issue #864 · hapijs/joi - GitHub
I am trying to store/retrieve an object that contains an array of either an ... work Joi.null() // This of course doesn't work...
Read more >Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. JSON data has the concept of null and empty arrays...
Read more >TypeError: Reduce of empty array with no initial value
This error is raised when an empty array is provided because no initial value can be returned in that case. Examples. Invalid cases....
Read more >17.7.0 API Reference - joi.dev
If the input is valid, then the error will be undefined . If the input is invalid, error is assigned a ValidationError object...
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 Free
Top 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
@mrjono1: Works, thx!
1.13.0 released to fix this