Skip to content

Commit

Permalink
馃う馃徎鈥嶁檪锔廸ix #9661 regression on required valueAsNumber (#9662)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 committed Dec 24, 2022
1 parent 508ddc8 commit d9b70a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/__tests__/logic/validateField.test.tsx
Expand Up @@ -36,6 +36,28 @@ describe('validateField', () => {
},
});

expect(
await validateField(
{
_f: {
mount: true,
name: 'test',
ref: { type: 'text', value: '', name: 'test' },
required: true,
valueAsNumber: true,
},
},
NaN,
false,
),
).toEqual({
test: {
ref: { type: 'text', value: '', name: 'test' },
message: '',
type: 'required',
},
});

expect(
await validateField(
{
Expand Down
1 change: 1 addition & 0 deletions src/logic/validateField.ts
Expand Up @@ -66,6 +66,7 @@ export default async <T extends NativeFieldValue>(
isUndefined(ref.value) &&
isUndefined(inputValue)) ||
inputValue === '' ||
ref.value === '' ||
(Array.isArray(inputValue) && !inputValue.length);
const appendErrorsCurry = appendErrors.bind(
null,
Expand Down

0 comments on commit d9b70a8

Please sign in to comment.