Skip to content

Commit

Permalink
fix: root path validations
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Apr 26, 2022
1 parent f148ddf commit 7ef990d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ function validatePath(
{ path }: ValidationPathSpec,
{ value, schema, ...rest },
): Promise<Error | void> {
return schema
.validateAt(path, value, rest)
.then(() => null)
.catch((err) => err);
const validation =
path === '' || path === '.'
? schema.validate(value, rest)
: schema.validateAt(path, value, rest);

return validation.then(() => null).catch((err) => err);
}

const EMPTY_TOUCHED = {};
Expand Down

0 comments on commit 7ef990d

Please sign in to comment.