requiredIfOtherFilled
requiredIfOtherFilled<
T>(path,sourceSelector,targetSelector,options?):void
Defined in: projects/ngx-signal-schema/src/lib/validators/required-if-other-filled.ts:25
Cross-field validator: Makes the target field required if the source field is filled.
This is useful for conditional dependencies where filling out one field requires filling out another.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”SchemaPath<T>
The common parent schema path.
sourceSelector
Section titled “sourceSelector”(p) => SchemaPath<unknown>
Function to select the “driving” field from the schema path tree.
targetSelector
Section titled “targetSelector”(p) => SchemaPath<unknown>
Function to select the field that becomes required from the schema path tree.
options?
Section titled “options?”object & ErrorOption
Optional configuration for the validator.
Returns
Section titled “Returns”void
Example
Section titled “Example”requiredIfOtherFilled( path, (p) => p.Street, // if this field is filled, (p) => p.HouseNumber // then this field is required);