Skip to content

Commit

Permalink
feat: remove valid fields from errors mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Oct 11, 2020
1 parent ca16af2 commit 1eee524
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/core/src/useForm.ts
Expand Up @@ -191,12 +191,18 @@ export function useForm(opts?: FormOptions) {
// Check if its a grouped field (checkbox/radio)
if (Array.isArray(fieldsById.value[field.name])) {
const group = fieldsById.value[field.name];
acc[field.name] = unwrap((group.find((f: any) => unwrap(f.checked)) || field).errorMessage);
const message = unwrap((group.find((f: any) => unwrap(f.checked)) || field).errorMessage);
if (message) {
acc[field.name] = message;
}

return acc;
}

acc[field.name] = unwrap(field.errorMessage);
const message = unwrap(field.errorMessage);
if (message) {
acc[field.name] = message;
}

return acc;
}, {});
Expand Down

0 comments on commit 1eee524

Please sign in to comment.