joi icon indicating copy to clipboard operation
joi copied to clipboard

Make SchemaMap warn if missing keys

Open kerrmarin-lvmh opened this issue 3 years ago • 0 comments

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: v14.15.1
  • module version: 17.1.1
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): nestjs
  • any other relevant information:

How can we help?

I'd like to know if there is a way to indicate with Joi that a validation schema is missing certain keys. The easiest way I can think of is through an example:


interface Config {
  readonly FOO: string
  readonly BAR: string
}

// This should not compile, saying that the object passed in is missing property BAR
export const configValidationSchema = Joi.object<Config>({
    FOO: Joi.string().required()
});

Apologies if this is a trivial question, still finding my bearings.

kerrmarin-lvmh avatar Sep 13 '21 08:09 kerrmarin-lvmh