6

我正在尝试使用ajv-keywords中的 if / then / else 关键字创建条件验证,但是我在浏览器控制台中收到以下错误:“未捕获的错误:关键字 if 已定义”。

我究竟做错了什么?

import * as ajvErrors from 'ajv-errors';
import * as ajvKeywords from 'ajv-keywords';

const ajv = new Ajv({ allErrors: true, jsonPointers: true });
ajvErrors(ajv);
ajvKeywords(ajv);

const schema = {
  if: {
    properties: {
      fundraiser: { type: 'string' }
    }
  },
  then: {
    required: ['title'],
  }
}
4

0 回答 0