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

Method _verifyOptionValues

src/cdk/listbox/listbox.ts:1015–1028  ·  view source on GitHub ↗

Verifies that the option values are valid.

()

Source from the content-addressed store, hash-verified

1013
1014 /** Verifies that the option values are valid. */
1015 private _verifyOptionValues() {
1016 if (this.options && (typeof ngDevMode === 'undefined' || ngDevMode)) {
1017 const selected = this.selectionModel.selected;
1018 const invalidValues = this._getInvalidOptionValues(selected);
1019
1020 if (!this.multiple && selected.length > 1) {
1021 throw Error('Listbox cannot have more than one selected value in single selection mode.');
1022 }
1023
1024 if (invalidValues.length) {
1025 throw Error('Listbox has selected values that do not match any of its options.');
1026 }
1027 }
1028 }
1029
1030 /**
1031 * Coerces a value into an array representing a listbox selection.

Callers 2

ngAfterContentInitMethod · 0.95
writeValueMethod · 0.95

Calls 1

Tested by

no test coverage detected