({
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;
};
})
| 535 | }; |
| 536 | |
| 537 | const executeBuiltInValidation = async ({ |
| 538 | fields, |
| 539 | onlyCheckValid, |
| 540 | name, |
| 541 | eventType, |
| 542 | context = { |
| 543 | valid: true, |
| 544 | runRootValidation: false, |
| 545 | }, |
| 546 | }: { |
| 547 | fields: FieldRefs; |
| 548 | onlyCheckValid?: boolean; |
| 549 | name?: FieldPath<TFieldValues> | FieldPath<TFieldValues>[]; |
| 550 | eventType: ValidateFormEventType; |
| 551 | context?: { |
| 552 | valid: boolean; |
| 553 | runRootValidation?: boolean; |
| 554 | }; |
| 555 | }) => { |
| 556 | if (props.validate) { |
| 557 | context.runRootValidation = true; |
| 558 | const result = await validateForm({ |
| 559 | name, |
| 560 | eventType, |
| 561 | }); |
| 562 | |
| 563 | if (!result) { |
| 564 | context.valid = false; |
| 565 | |
| 566 | if (onlyCheckValid) { |
| 567 | return context.valid; |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | for (const name in fields) { |
| 573 | const field = fields[name]; |
| 574 | |
| 575 | if (field) { |
| 576 | const { _f, ...fieldValue } = field as Field; |
| 577 | |
| 578 | if (_f) { |
| 579 | const isFieldArrayRoot = _names.array.has(_f.name); |
| 580 | const isPromiseFunction = |
| 581 | field._f && hasPromiseValidation((field as Field)._f); |
| 582 | |
| 583 | if (isPromiseFunction && _proxyFormState.validatingFields) { |
| 584 | _updateIsValidating([_f.name], true); |
| 585 | } |
| 586 | |
| 587 | const fieldError = await validateField( |
| 588 | field as Field, |
| 589 | _names.disabled, |
| 590 | _formValues, |
| 591 | shouldDisplayAllAssociatedErrors, |
| 592 | _options.shouldUseNativeValidation && !onlyCheckValid, |
| 593 | isFieldArrayRoot, |
| 594 | ); |
no test coverage detected