( errors: ErrorObject[], et: ErrorTranslator, t: Translator, schema?: i18nJsonSchema, uischema?: UISchemaElement, path?: string )
| 128 | * All errors must correspond to the given schema, uischema or path. |
| 129 | */ |
| 130 | export const getCombinedErrorMessage = ( |
| 131 | errors: ErrorObject[], |
| 132 | et: ErrorTranslator, |
| 133 | t: Translator, |
| 134 | schema?: i18nJsonSchema, |
| 135 | uischema?: UISchemaElement, |
| 136 | path?: string |
| 137 | ) => { |
| 138 | if (errors.length > 0 && t) { |
| 139 | // check whether there is a special message which overwrites all others |
| 140 | const customErrorKey = getI18nKey(schema, uischema, path, 'error.custom'); |
| 141 | const specializedErrorMessage = t(customErrorKey, undefined, { |
| 142 | schema, |
| 143 | uischema, |
| 144 | path, |
| 145 | errors, |
| 146 | }); |
| 147 | if (specializedErrorMessage !== undefined) { |
| 148 | return specializedErrorMessage; |
| 149 | } |
| 150 | } |
| 151 | return formatErrorMessage(errors.map((error) => et(error, t, uischema))); |
| 152 | }; |
| 153 | |
| 154 | /** |
| 155 | * This can be used to internationalize the label of the given Labelable (e.g. UI Schema elements). |
no test coverage detected
searching dependent graphs…