question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow null doesn't work on array and object

See original GitHub issue

Hi,

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:closed
  • Created 2 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
RatTaccommented, Apr 26, 2021

@mrjono1: Works, thx!

0reactions
mrjono1commented, Apr 26, 2021

1.13.0 released to fix this

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found