I am trying to create conditional validation using if / then / else keywords from ajv-keywords, however I am getting the following error in my browser console: “Uncaught Error: Keyword if is already defined”.
What am I doing wrong?
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'],
}
}