Show password strength on the signup form

Angular · Angular · beginner · greenfield

Adds the signup password meter as a standalone component on signals. The score and the unmet-rules list are both computed from the same rule table, so the label and the checklist can never disagree. The strength line doubles as a persistent status live region, and empty input shows no feedback text, per the spec.

Requirements

Files touched

--- src/app/signup/password-strength.component.ts
+import { Component, computed, signal } from '@angular/core';
+
+interface StrengthRule {
+  id: string;
+  label: string;
+  test: (password: string) => boolean;
+}
+
+const RULES: StrengthRule[] = [
+  { id: 'length', label: 'At least 12 characters', test: (p) => p.length >= 12 },
+  { id: 'case', label: 'Upper and lower case letters (a–z and A–Z)', test: (p) => /[a-z]/.test(p) && /[A-Z]/.test(p) },
+  { id: 'digit', label: 'At least one digit (0–9)', test: (p) => /[0-9]/.test(p) },
+  { id: 'symbol', label: 'At least one symbol (any character that is not an ASCII letter or digit)', test: (p) => /[^A-Za-z0-9]/.test(p) },
+];
+
+@Component({
+  selector: 'app-password-strength',
+  standalone: true,
+  template: `
+    <label for="new-password">New password</label>
+    <input
+      id="new-password"
+      type="password"
+      autocomplete="new-password"
+      aria-describedby="password-strength-status"
+      [value]="password()"
+      (input)="onInput($event)"
+    />
+    <p id="password-strength-status" class="strength" role="status">

Review this PR

Angular practice