diff --git a/src/core/json-schema-components.jsx b/src/core/json-schema-components.jsx index f531341e312..25a09d9cb4f 100644 --- a/src/core/json-schema-components.jsx +++ b/src/core/json-schema-components.jsx @@ -345,6 +345,31 @@ export class JsonSchema_boolean extends Component { } } +const stringifyObjectErrors = (errors) => { + return errors.map(err => { + const meta = err.propKey !== undefined ? err.propKey : err.index + let stringError = typeof err === "string" ? err : typeof err.error === "string" ? err.error : null + + if(!meta && stringError) { + return stringError + } + let currentError = err.error + let path = `/${err.propKey}` + while(typeof currentError === "object") { + const part = currentError.propKey !== undefined ? currentError.propKey : currentError.index + if(part === undefined) { + break + } + path += `/${part}` + if (!currentError.error) { + break + } + currentError = currentError.error + } + return `${path}: ${currentError}` + }) +} + export class JsonSchema_object extends PureComponent { constructor() { super() @@ -372,18 +397,18 @@ export class JsonSchema_object extends PureComponent { } = this.props const TextArea = getComponent("TextArea") + errors = errors.toJS ? errors.toJS() : Array.isArray(errors) ? errors : [] return (