Forms sort code

From Legal-and-General/canopy · View interactive version

Forms sort code is an AI agent skill from the GitHub repository Legal-and-General/canopy. Best practices for the Canopy Sort Code directive. Trigger when capturing and validating UK bank sort codes in a form in an Angular project using Canopy.

How to use this skill

Skill file

Canopy Sort Code — Best Practices

This skill provides usage guidance for the Canopy lgSortCode directive from @legal-and-general/canopy.

Apply this skill whenever you capture or validate a UK bank sort code.


Import

import {
  LgSortCodeDirective,
  LgInputFieldComponent,
  LgInputDirective,
  LgHintComponent,
} from '@legal-and-general/canopy';

Basic Usage

Both lgInput and lgSortCode must be present on the same <input> element. Always include the exact hint text shown below.

<lg-input-field>
  Sort code
  <lg-hint>Must be 6 digits long, for example 00-00-00</lg-hint>
  <input lgInput lgSortCode formControlName="sortCode" />
</lg-input-field>

Validation

The lgSortCode directive automatically applies required and pattern validators. The pattern validator accepts:

On blur, the value is auto-formatted to 00-00-00.

For displaying validation error messages, use the LgValidationComponent — see the forms-validation skill.


Design Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.