1 | import type {MacroKeywordDefinition} from "ajv"
|
2 |
|
3 | export default function getDef(): MacroKeywordDefinition {
|
4 | return {
|
5 | keyword: "prohibited",
|
6 | type: "object",
|
7 | schemaType: "array",
|
8 | macro: function (schema: string[]) {
|
9 | if (schema.length === 0) return true
|
10 | if (schema.length === 1) return {not: {required: schema}}
|
11 | return {not: {anyOf: schema.map((p) => ({required: [p]}))}}
|
12 | },
|
13 | metaSchema: {
|
14 | type: "array",
|
15 | items: {type: "string"},
|
16 | },
|
17 | }
|
18 | }
|
19 |
|
20 | module.exports = getDef
|