compose
compose<
T>(base, …extension):Schema<T>
Defined in: projects/ngx-signal-schema/src/lib/composition/compose.ts:32
Combines multiple schemas into a single schema.
The compose function allows extending a base schema with additional schemas or conditions.
This is particularly useful for reusing existing validation logic and augmenting it with
context-specific conditions (e.g., disabling fields).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”SchemaOrSchemaFn<T>
The base schema serving as the foundation.
extension
Section titled “extension”…SchemaOrSchemaFn<T>[]
Additional schemas or conditions to be applied to the base schema.
Returns
Section titled “Returns”Schema<T>
A new Schema<T> containing all combined conditions.
Examples
Section titled “Examples”// Combining multiple schemasconst combinedSchema = compose(MyDefaultSchema, RequiredFieldsSchema, ExtendedSchema);// Extending a schema with a disable ruleconst combinedSchema = compose(MyDefaultSchema, disabled);// Extending a schema with complex conditionsconst combinedSchema = compose(MyDefaultSchema, (fieldPath) => { disabled(fieldPath.firstname); hidden(fieldPath.lastname);});