awesome-ajv-errors
Version:
Prettified AJV errors
13 lines (12 loc) • 708 B
JavaScript
import { getTypedContext } from "../../types.js";
export function prettify(context) {
const { styleManager: { style, pathDescription }, printCode, dataPath, error: { params: { missingProperty } }, } = getTypedContext(context);
const [prePath, pathExpr, postPath] = pathDescription(context, 'value');
const title = style.title(`The ${prePath}`) +
pathExpr +
style.title(`${postPath} is missing required property `) +
style.pathDescription(missingProperty);
const codeFrame = printCode('add missing property ' +
style.pathDescription(missingProperty), context.parsedJson, { path: dataPath.simplePath, markIdentifier: false });
return { title, codeFrame };
}