MCPcopy Create free account
hub / github.com/angular/components / validate

Method validate

src/aria/private/tree/tree.ts:378–394  ·  view source on GitHub ↗

Returns a set of violations

()

Source from the content-addressed store, hash-verified

376
377 /** Returns a set of violations */
378 validate(): string[] {
379 const violations: string[] = [];
380
381 if (!this.inputs.multi() && this.inputs.value().length > 1) {
382 violations.push(
383 `A single-select tree should not have multiple selected options. Selected options: ${this.inputs.value().join(', ')}`,
384 );
385 }
386
387 const values = this.inputs.items().map(t => t.value());
388 const duplicates = values.filter((val, idx) => values.indexOf(val) !== idx);
389 if (duplicates.length > 0) {
390 violations.push(`Duplicate tree item value '${duplicates[0]}' detected inside ngTree.`);
391 }
392
393 return violations;
394 }
395
396 /**
397 * Sets the tree to it's default initial state.

Callers

nothing calls this directly

Calls 3

pushMethod · 0.65
valueMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected