Skip to content

applyIf

applyIf<T>(path, when, thenSchema, elseSchema): void

Defined in: projects/ngx-signal-schema/src/lib/composition/apply-if.ts:18

Conditionally applies one of two schemas based on a predicate.

This is a structural helper that allows branching validation logic.

T

SchemaPath<T>

The schema path to apply the conditions to.

LogicFn<T, boolean>

A predicate function that receives the validation context and returns a boolean.

SchemaOrSchemaFn<T>

The schema or conditions to apply if the predicate is true.

SchemaOrSchemaFn<T>

The schema or conditions to apply if the predicate is false.

void

applyIf(path, valueEquals(path.isCompany, true), CompanySchema, PersonSchema);