Skip to content

Commit

Permalink
馃悶 closes: #9709 remove ref.value check (#9710)
Browse files Browse the repository at this point in the history
* WIP 馃悰fix(Validation): remove ref.value check

Closes: #9709

* Update validateField.ts

* Update validateField.ts

* Update validateField.test.tsx

* Update validateField.test.tsx

Co-authored-by: Beier (Bill) <bluebill1049@hotmail.com>
  • Loading branch information
moshyfawn and bluebill1049 committed Jan 3, 2023
1 parent 1647bb2 commit 17fd388
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 17fd388

Please sign in to comment.