Skip to content

Commit 432c7c2

Browse files
committed
Fix #80: Display errors on top level arrays
1 parent edcdcf2 commit 432c7c2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ui.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ export function getArrayFormRow(args) {
285285
let coords = name; // coordinates for insertion and deletion
286286

287287
if (rows.length || (!rows.length && !groups.length)) {
288+
let rowError;
289+
290+
if (!groups.length) {
291+
rowError = args.errorMap[getCoordsFromName(coords)];
292+
if (typeof rowError === 'string')
293+
rowError = [rowError];
294+
}
295+
288296
rows = (
289297
<FormGroup
290298
level={level}
@@ -295,6 +303,7 @@ export function getArrayFormRow(args) {
295303
onEdit={args.onKeyEdit}
296304
key={'row_group_' + name}
297305
>
306+
{rowError && rowError.map((error, i) => <div className="rjf-error-text" key={i}>{error}</div>)}
298307
{rows}
299308
</FormGroup>
300309
);
@@ -311,11 +320,11 @@ export function getArrayFormRow(args) {
311320
}
312321
}
313322

314-
let groupError = args.errorMap[getCoordsFromName(coords)];
315-
if (typeof groupError === 'string')
316-
groupError = [groupError];
317-
318323
if (groups.length) {
324+
let groupError = args.errorMap[getCoordsFromName(coords)];
325+
if (typeof groupError === 'string')
326+
groupError = [groupError];
327+
319328
let groupTitle = schema.title ? <GroupTitle editable={args.editable} onEdit={args.onKeyEdit}>{schema.title}</GroupTitle> : null;
320329

321330
groups = (

0 commit comments

Comments
 (0)