@dappnode/schemas
Version:
A shared TypeScript JSON schemas and its validation functions for the manifest and setup wizard dappnode files
56 lines • 1.73 kB
JavaScript
// validate.errors = [
// {
// keyword: "pattern",
// dataPath: "/avatar",
// schemaPath: "#/properties/avatar/pattern",
// params: { pattern: "^/(ipfs|bzz)/w+$" },
// message: 'should match pattern "^/(ipfs|bzz)/w+$"'
// },
// {
// keyword: "pattern",
// dataPath: "/image/hash",
// schemaPath: "#/properties/image/properties/hash/pattern",
// params: { pattern: "^/(ipfs|bzz)/w+$" },
// message: 'should match pattern "^/(ipfs|bzz)/w+$"'
// },
// {
// keyword: "type",
// dataPath: "/image/size",
// schemaPath: "#/properties/image/properties/size/type",
// params: { type: "number" },
// message: "should be number"
// },
// {
// keyword: "pattern",
// dataPath: "/image/size",
// schemaPath: "#/properties/image/properties/size/pattern",
// params: { pattern: "^d+$" },
// message: 'should match pattern "^d+$"'
// },
// {
// keyword: "required",
// dataPath: "",
// schemaPath: "#/required",
// params: { missingProperty: "license" },
// message: "should have required property 'license'"
// }
// ];
/**
*
* @param errorObject from AJV:
* {
* keyword: "pattern",
* dataPath: "/avatar",
* schemaPath: "#/properties/avatar/pattern",
* params: { pattern: "^/(ipfs|bzz)/w+$" },
* message: 'should match pattern "^/(ipfs|bzz)/w+$"'
* }
* @returns errorMessage:
* "manifest.avatar should match pattern "^/(ipfs|bzz)/w+$""
*/
export function processError(errorObject, releaseFileType) {
const { schemaPath, message } = errorObject;
const path = `${releaseFileType}${schemaPath}`.replace(new RegExp("/", "g"), ".");
return `${path} ${message}`;
}
//# sourceMappingURL=utils.js.map