Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤦🏻‍♂️ fix #9661 regression on required valueAsNumber #9662

Merged
merged 1 commit into from Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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