Files
MyAiConfiguration/shared/rules/angular/references/forms-and-routing.md
T
Julian LechnerandClaude Opus 5.5 6159c6373c
CI / CI configuration security checks (pull_request) Successful in 2s
CI / Capabilities and shell quality (pull_request) Successful in 15s
CI / Python tests and compilation (pull_request) Successful in 36s
CI / QMD unit tests (pull_request) Successful in 7s
CI / Build and inspect generated packages (pull_request) Successful in 16s
CI / Bash integration and installation guards (pull_request) Failing after 51s
CI / PowerShell tests on Ubuntu (pull_request) Failing after 1m45s
CI / Installed client configuration smoke tests (pull_request) Canceled after 1m24s
docs(rules): fix contradictions, update technical rules, enforce rule structure
- Resolve contradictions: authorization is never a skipped "boundary check";
  one browser token policy (BFF/HttpOnly cookies first, RFC 10017); one
  sanitizer-bypass rule; Angular responses are unknown until validated.
- Add security rules for AI/LLM integration and Java XXE, concrete crypto
  and password-hashing parameters, and RFC 8725 JWT validation.
- Update version-dependent guidance after checking official sources:
  Angular 22, TypeScript 6/7, Node 24+, .NET 10/C# 14, JDK 21-25, Spring
  Boot 4; add a Spring Boot and Spring Security topic.
- Give every rule a unique level-1 title and scope line, keep language
  security files to language specifics, and fix routing for inbound vs
  outbound HTTP, XML parsing, and WPF/Angular parent rules.
- Validate rule structure and routing in validate-config.py, with tests.
- Fix CI issues found by a local run: shellcheck directive order, pinned
  ruff rule set, Invoke-Python test mock, CRLF-tolerant package checks,
  Windows-only credential test, and refreshed prompt-budget baselines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 10:51:08 +01:00

1.9 KiB

Angular Forms and Routing

Apply these rules when building Angular forms, validation, routes, guards, or resolvers.

Forms

  • Follow the form approach the project uses. For non-trivial forms, use typed reactive forms (FormGroup, FormControl, NonNullableFormBuilder; nonNullable controls where reset should restore the initial value) and never Untyped* classes in new code.
  • Signal forms (@angular/forms/signals) are stable since Angular 22. Use them for new forms only when the project is on 22+ and has adopted them; do not migrate existing forms unasked.
  • Keep validation rules centralized and reusable where practical.
  • Client-side validation is user experience; the server must validate every submission. Never treat client-side validation as a security boundary.
  • Keep form state separate from domain state when useful.
  • Avoid large components that combine layout, validation, persistence and business logic.
  • Display validation errors consistently.
  • Preserve user input when recoverable errors occur.

Routing

  • Keep route definitions explicit and predictable.
  • Prefer lazy loading for larger feature areas with loadComponent or loadChildren pointing to standalone route arrays.
  • Write new guards and resolvers as functions (CanActivateFn, ResolveFn); keep class-based guards where the project uses them, since they remain supported.
  • Use withComponentInputBinding() to bind route parameters to component inputs where the project enables it.
  • Avoid loading large feature bundles eagerly without need.
  • Use route guards only for navigation behavior, not as a security boundary.
  • Authorization must still be enforced on the backend.
  • Keep resolvers focused.
  • Avoid expensive work during navigation unless required.
  • Route and query parameters arrive as string | null. Parse and validate them before use and treat them as untrusted input.
  • Do not rely on client-side routing state for sensitive authorization decisions.