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

Function toObservable

packages/forms/src/validators.ts:609–621  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

607}
608
609export function toObservable(value: any): Observable<any> {
610 const obs = isPromise(value) ? from(value) : value;
611 if ((typeof ngDevMode === 'undefined' || ngDevMode) && !isSubscribable(obs)) {
612 let errorMessage = `Expected async validator to return Promise or Observable.`;
613 // A synchronous validator will return object or null.
614 if (typeof value === 'object') {
615 errorMessage +=
616 ' Are you using a synchronous validator where an async validator is expected?';
617 }
618 throw new RuntimeError(RuntimeErrorCode.WRONG_VALIDATOR_RETURN_TYPE, errorMessage);
619 }
620 return obs;
621}
622
623function mergeErrors(arrayOfErrors: (ValidationErrors | null)[]): ValidationErrors | null {
624 let res: {[key: string]: any} = {};

Callers 1

_runAsyncValidatorFunction · 0.90

Calls 2

isPromiseFunction · 0.85
isSubscribableFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…