Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1x 122x 122x 80x 42x 1x 41x | import type { AbstractControl } from '@angular/forms'; /** * Safely extract the value from a control, expecting it to be a string or nullish. * @throws TypeError - Control value is not nullish and not a string. */ export const getPasswordControlValue = (control: AbstractControl<unknown>): string | null => { const { value } = control; // Like Validators.email, rely on Validators.required to check for blank passwords. if (value == undefined || value === '') { return null; // eslint-disable-line unicorn/no-null -- ValidatorFn returns null } if (typeof value !== 'string') { throw new TypeError(`Invalid Control Value Type: '${typeof value}'`); } return value; }; |