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

Remove ref.value check #9710

Merged
merged 5 commits into from Jan 3, 2023
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
6 changes: 4 additions & 2 deletions src/__tests__/logic/validateField.test.tsx
Expand Up @@ -36,13 +36,15 @@ describe('validateField', () => {
},
});

const input = document.createElement('input');

expect(
await validateField(
{
_f: {
mount: true,
name: 'test',
ref: { type: 'text', value: '', name: 'test' },
ref: input,
required: true,
valueAsNumber: true,
},
Expand All @@ -52,7 +54,7 @@ describe('validateField', () => {
),
).toEqual({
test: {
ref: { type: 'text', value: '', name: 'test' },
ref: input,
message: '',
type: 'required',
},
Expand Down
3 changes: 2 additions & 1 deletion src/logic/validateField.ts
Expand Up @@ -11,6 +11,7 @@ import isCheckBoxInput from '../utils/isCheckBoxInput';
import isEmptyObject from '../utils/isEmptyObject';
import isFileInput from '../utils/isFileInput';
import isFunction from '../utils/isFunction';
import isHTMLElement from '../utils/isHTMLElement';
import isMessage from '../utils/isMessage';
import isNullOrUndefined from '../utils/isNullOrUndefined';
import isObject from '../utils/isObject';
Expand Down Expand Up @@ -65,8 +66,8 @@ export default async <T extends NativeFieldValue>(
((valueAsNumber || isFileInput(ref)) &&
isUndefined(ref.value) &&
isUndefined(inputValue)) ||
(isHTMLElement(ref) && ref.value === '') ||
inputValue === '' ||
ref.value === '' ||
(Array.isArray(inputValue) && !inputValue.length);
const appendErrorsCurry = appendErrors.bind(
null,
Expand Down