Skip to content

Commit 3b83885

Browse files
authored
Merge pull request #122 from shane-js/patch-1
Update README.md TypeScript section to recommend Ajv JSONSchemaType utility type
2 parents 1398af0 + eedc005 commit 3b83885

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ Coming from `express-jsonschema`? Read the [migration notes](docs/migrating-from
7777
### Schemas in TypeScript
7878

7979
If you're writing JSON schemas in TypeScript, you'll need to use the
80-
`AllowedSchema` type e.g.
80+
`AllowedSchema` type and this can be combined with [ajv's recommended `JSONSchemaType` type](https://ajv.js.org/guide/typescript.html) e.g.
8181

8282
```typescript
83+
import { JSONSchemaType } from "ajv";
8384
import { AllowedSchema } from "express-json-validator-middleware";
8485

85-
const addressSchema: AllowedSchema = {
86+
type Address = { street: string; };
87+
const addressSchema: AllowedSchema & JSONSchemaType<Address> = {
8688
type: "object",
8789
required: ["street"],
8890
properties: {

0 commit comments

Comments
 (0)