function formatErrors(errors) {
    return errors.map(error => {
        if (error.keyword === "additionalProperties") {
            const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;

            return `Unexpected top-level property "${formattedPropertyPath}"`;
        }
        if (error.keyword === "type") {
            const formattedField = error.dataPath.slice(1);
            const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
            const formattedValue = JSON.stringify(error.data);

            return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
        }

        const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;

        return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
    }).map(message => `\t- ${message}.\n`).join("");
}
function formatErrors(errors) {
    return errors.map(error => {
        if (error.keyword === "additionalProperties") {
            const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;

            return `Unexpected top-level property "${formattedPropertyPath}"`;
        }
        if (error.keyword === "type") {
            const formattedField = error.dataPath.slice(1);
            const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
            const formattedValue = JSON.stringify(error.data);

            return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
        }

        const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;

        return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
    }).map(message => `\t- ${message}.\n`).join("");
}
function formatErrors ( errors ) { return errors . map ( error => { if ( error . keyword === "additionalProperties" ) { const formattedPropertyPath = error . dataPath . length ? ` ${ error . dataPath . slice ( 1 ) } ${ error . params . additionalProperty } ` : error . params . additionalProperty ; return ` ${ formattedPropertyPath } ` ; } if ( error . keyword === "type" ) { const formattedField = error . dataPath . slice ( 1 ) ; const formattedExpectedType = Array . isArray ( error . schema ) ? error . schema . join ( "/" ) : error . schema ; const formattedValue = JSON . stringify ( error . data ) ; return ` ${ formattedField } ${ formattedExpectedType } \` ${ formattedValue } \` ` ; } const field = error . dataPath [ 0 ] === "." ? error . dataPath . slice ( 1 ) : error . dataPath ; return ` ${ field } ${ error . message } ${ JSON . stringify ( error . data ) } ` ; } ) . map ( message => ` \t ${ message } \n ` ) . join ( "" ) ; }
Formats an array of schema validation errors.
@param {Array} errors An array of error messages to format.
@returns {string} Formatted error message
Formats an array of schema validation errors .
Format an array of errors