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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”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.
thenSchema
Section titled “thenSchema”SchemaOrSchemaFn<T>
The schema or conditions to apply if the predicate is true.
elseSchema
Section titled “elseSchema”SchemaOrSchemaFn<T>
The schema or conditions to apply if the predicate is false.
Returns
Section titled “Returns”void
Example
Section titled “Example”applyIf(path, valueEquals(path.isCompany, true), CompanySchema, PersonSchema);