• Overview
@angular/forms/signals

applyWhenValue

function

API

function applyWhenValue<TValue, TNarrowed extends TValue>(
  path: FieldPath<TValue>,
  predicate: (value: TValue) => value is TNarrowed,
  schema: SchemaOrSchemaFn<TNarrowed>,
): void;
function applyWhenValue<TValue>(
  path: FieldPath<TValue>,
  predicate: (value: TValue) => boolean,
  schema: NoInfer<SchemaOrSchemaFn<TValue>>,
): void;
function applyWhenValue<TValue, TNarrowed>(path: FieldPath<TValue>, predicate: (value: TValue) => value is TNarrowed, schema: SchemaOrSchemaFn<TNarrowed>): void;

Conditionally applies a predefined schema to a given FieldPath.

@parampathFieldPath<TValue>

The target path to apply the schema to.

@parampredicate(value: TValue) => value is TNarrowed

A type guard that accepts a value T and returns true if T is of type TNarrowed.

@paramschemaSchemaOrSchemaFn<TNarrowed>

The schema to apply to the field when predicate returns true.

@returnsvoid
function applyWhenValue<TValue>(path: FieldPath<TValue>, predicate: (value: TValue) => boolean, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;

Conditionally applies a predefined schema to a given FieldPath.

@parampathFieldPath<TValue>

The target path to apply the schema to.

@parampredicate(value: TValue) => boolean

A function that accepts a value T and returns true when the schema should be applied.

@paramschemaNoInfer<SchemaOrSchemaFn<TValue>>

The schema to apply to the field when predicate returns true.

@returnsvoid
Jump to details