UNPKG

@theme-json/validate

Version:
20 lines (19 loc) 479 B
/** * External dependencies */ import _ from 'lodash'; import pc from 'picocolors'; export function errorsText(errors) { if (!errors || errors.length === 0) { return 'No errors'; } return (errors .map((err) => { if (!_.isEmpty(err.instancePath)) { return `${err.instancePath} ${err.message}`; } return err.message; }) .reduce((text, msg) => `${text}${pc.red('error')} ${msg}\n`, '') || ''); }