chrome:shell.skip

generated:catalog.entry.validation-rules.title

generated:catalog.entry.validation-rules.description

@xngui/components/validation-rules
@xngui/components/validation-rules

chrome:demo.section

chrome:demo.preview

  • At least 8 characters
  • One uppercase letter
  • One number
demo-preview:hints.category.navigation:
Tab
demo-preview:hints.category.focus:
Focus
demo-preview:hints.category.shortcuts:
Enter
demo-preview:hints.category.timing:
Blur
import { Component, signal } from '@angular/core';
import { form, FormField } from '@angular/forms/signals';
 
import { XForm, minLength } from '@xngui/components/form';
import { XFormField } from '@xngui/components/form-field';
import { XPasswordInput } from '@xngui/components/password-input';
import type { XValidationRuleDef } from '@xngui/components/validation-rules';
import { XValidationRules } from '@xngui/components/validation-rules';
 
const passwordRuleDefs: XValidationRuleDef[] = [
{ kind: 'minLength', label: 'At least 8 characters' },
{ label: 'One uppercase letter', test: (v) => typeof v === 'string' && [A-Z].test(v) },
{ label: 'One number', test: (v) => typeof v === 'string' && \d.test(v) },
];
 
@Component({
selector: 'app-example',
imports: [FormField, XForm, XFormField, XPasswordInput, XValidationRules],
templateUrl: './validation-rules.component.html',
})
export class ExampleComponent {
protected readonly passwordRulesId = 'password-rules';
 
private readonly model = signal({ password: '' });
 
protected readonly demoForm = form(this.model, (path) => {
minLength(path.password, 8, { message: 'At least 8 characters' });
});
}

chrome:demo.events.title

chrome:demo.events.empty

chrome:demo.api.title

x-validation-rules

chrome:demo.api.col.property
chrome:demo.api.col.type
chrome:demo.api.col.default
chrome:demo.api.col.description
field
FieldTree<unknown>
—
Signal Forms field — same `FieldTree` path as `[formField]` on the bound control.
rules
readonly XValidationRuleDef[]
[]
Rule definitions — `kind` matches validator errors; `test` for custom checks.
title
string
''
Optional heading above the list.
ariaLabel
string
''
Accessible name for the list when `title` is empty.
listId
string
—
Stable id for `aria-describedby` on the related control.
validateOn
XValidateOn
—
Overrides parent `x-form` / `x-form-field` validation timing.
size
XSize
—
Visual size tier — falls back to parent `x-form` then XConfigService when unset.
density
XDensity
—
Spacing offsets — orthogonal to `size`; falls back to parent `x-form` then XConfigService when unset.