How would you convert a typescript enum to valid JSON Schema MongoDB could understand?

Hi there.

Let’s say I in typescript have an interface like this:

interface Foo {
   bar: 'mongo' 
}

In other words, Foo objects must have a bar property with the exact string mongo.

Is this possible to express in the MongoDB Validation schema somehow?

In JSON schema v7 we can solve this with:

bar: {
  type: "string",
  "const": "mongo"
}