MCPcopy Index your code
hub / github.com/angular/angular / setSubmissionErrors

Function setSubmissionErrors

packages/forms/signals/src/api/structure.ts:511–532  ·  view source on GitHub ↗

* Sets a list of submission errors to their individual fields. * * @param submittedField The field that was submitted, resulting in the errors. * @param errors The errors to set.

(
  submittedField: FieldNode,
  errors: OneOrMany<ValidationError.WithOptionalFieldTree>,
)

Source from the content-addressed store, hash-verified

509 * @param errors The errors to set.
510 */
511function setSubmissionErrors(
512 submittedField: FieldNode,
513 errors: OneOrMany<ValidationError.WithOptionalFieldTree>,
514) {
515 if (!isArray(errors)) {
516 errors = [errors];
517 }
518 const errorsByField = new Map<FieldNode, ValidationError.WithFieldTree[]>();
519 for (const error of errors) {
520 const errorWithField = addDefaultField(error, submittedField.fieldTree);
521 const field = errorWithField.fieldTree() as FieldNode;
522 let fieldErrors = errorsByField.get(field);
523 if (!fieldErrors) {
524 fieldErrors = [];
525 errorsByField.set(field, fieldErrors);
526 }
527 fieldErrors.push(errorWithField);
528 }
529 for (const [field, fieldErrors] of errorsByField) {
530 field.submitState.submissionErrors.set(fieldErrors);
531 }
532}

Callers 1

submitFunction · 0.85

Calls 6

isArrayFunction · 0.90
addDefaultFieldFunction · 0.90
getMethod · 0.65
setMethod · 0.65
fieldTreeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…