Skip to content

How to generate a hashmap? #163

Answered by mrjono1
JanMalch asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, currently support hasn't been added for .pattern() but I received a PR recently that should solve this issue
This block is from the readme.md

export const WalletSchema = Joi.object({
  usd: Joi.number().required(),
  eur: Joi.number().required()
})
  .unknown()
  .meta({ className: 'Wallet', unknownType: 'number' });

I think if you add the unknownType property to .meta() that should fix the issue with your second attempt like this

export const PersonsSchema = Joi.object()
  .unknown()
  .pattern(/\w/, PersonSchema)
  .meta({ className: 'Persons', unknownType: 'Person' });

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JanMalch
Comment options

Answer selected by JanMalch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants