Skip to content

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.

T

SchemaPath<T>

The common parent schema path.

(p) => SchemaPath<unknown>

Function to select the “driving” field from the schema path tree.

(p) => SchemaPath<unknown>

Function to select the field that becomes required from the schema path tree.

object & ErrorOption

Optional configuration for the validator.

void

requiredIfOtherFilled(
path,
(p) => p.Street, // if this field is filled,
(p) => p.HouseNumber // then this field is required
);