({
fields,
onlyCheckValid,
name,
eventType,
context = {
valid: true,
runRootValidation: false,
},
}: {
fields: FieldRefs;
onlyCheckValid?: boolean;
name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[];
eventType: ValidateFormEventType;
context?: {
valid: boolean;
runRootValidation?: boolean;
};
})
| 618 | }; |
| 619 | |
| 620 | const executeBuiltInValidation = async ({ |
| 621 | fields, |
| 622 | onlyCheckValid, |
| 623 | name, |
| 624 | eventType, |
| 625 | context = { |
| 626 | valid: true, |
| 627 | runRootValidation: false, |
| 628 | }, |
| 629 | }: { |
| 630 | fields: FieldRefs; |
| 631 | onlyCheckValid?: boolean; |
| 632 | name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[]; |
| 633 | eventType: ValidateFormEventType; |
| 634 | context?: { |
| 635 | valid: boolean; |
| 636 | runRootValidation?: boolean; |
| 637 | }; |
| 638 | }) => { |
| 639 | if (props.validate) { |
| 640 | context.runRootValidation = true; |
| 641 | const result = await validateForm({ |
| 642 | name, |
| 643 | eventType, |
| 644 | }); |
| 645 | |
| 646 | if (!result) { |
| 647 | context.valid = false; |
| 648 | |
| 649 | if (onlyCheckValid) { |
| 650 | return context.valid; |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | for (const name in fields) { |
| 656 | const field = fields[name]; |
| 657 | |
| 658 | if (field) { |
| 659 | const { _f, ...fieldValue } = field as Field; |
| 660 | |
| 661 | if (_f) { |
| 662 | const isFieldArrayRoot = _names.array.has(_f.name); |
| 663 | const isPromiseFunction = |
| 664 | field._f && hasPromiseValidation((field as Field)._f); |
| 665 | const shouldTrackIsValidatingState = |
| 666 | _proxyFormState.validatingFields || |
| 667 | _proxyFormState.isValidating || |
| 668 | _proxySubscribeFormState.validatingFields || |
| 669 | _proxySubscribeFormState.isValidating; |
| 670 | |
| 671 | if (isPromiseFunction && shouldTrackIsValidatingState) { |
| 672 | _updateIsValidating([_f.name], true); |
| 673 | } |
| 674 | |
| 675 | const fieldError = await validateField( |
| 676 | field as Field, |
| 677 | _names.disabled, |
no test coverage detected
searching dependent graphs…