npm install --save-dev @satisfactory-dev/ajv-utilities
import Ajv from 'ajv/dist/2020';
import {compile, FailedToCompileSchema} from '@satisfactory-dev/ajv-utilities';
const schema = {type: 'string'};
try {
const check = compile(new Ajv(), schema);
} catch (err) {
if (err instanceof FailedToCompileSchema) {
console.error('failed to compile', err);
} else {
console.error('unknown error', err);
}
}
import Ajv from 'ajv/dist/2020';
import standalone from 'ajv/dist/standalone';
import {compile, esmify} from '@satisfactory-dev/ajv-utilities';
const ajv = new Ajv();
await writeFile(
'./standalone-validator.mjs',
esmify(standalone(ajv, compile(ajv, schema)))
);