Spec-Zone.ru › Angular

pattern

Binds a validator to the given path that requires the value to match a specific regex pattern. This function can only be called on string paths. In addition to binding a validator, this function adds PATTERN property to the field.

Signal Form Pattern Validation

API

function pattern<TPathKind extends PathKind = PathKind.Root>(
  path: SchemaPath<string, 1, TPathKind>,
  pattern: RegExp | LogicFn<string | undefined, RegExp | undefined, TPathKind>,
  config?: BaseValidatorConfig<string, TPathKind> | undefined,
): void;
@parampathSchemaPath<string, 1, TPathKind>

Path of the field to validate

@parampatternRegExp | LogicFn<string | undefined, RegExp | undefined, TPathKind>

The RegExp pattern to match, or a LogicFn that returns the RegExp pattern.

@paramconfigBaseValidatorConfig<string, TPathKind> | undefined

Optional, allows providing any of the following options:

  • error: Custom validation error(s) to be used instead of the default ValidationError.pattern(pattern) or a function that receives the FieldContext and returns custom validation error(s).
@returnsvoid

Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/forms/signals/pattern

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API