Skip to main content

ComposableValidator

Validator that may return errors directly or compose one or more validators dynamically.

Import

import type { ComposableValidator } from '@ngblocks/form-nodes';

When to use it

Use for a synchronous rule that can return another validator or a nested validator collection. Returned compositions retain the validation pipeline's state and error handling.

Declaration

type ComposableValidator<TValue, TField extends AnyNode = ValidatorNode> = (context: ValidatorContext<TValue, ValidatorApi<TValue>, TField>) => ComposableValidationResult<TValue, TField>;

Type parameters

ParameterConstraintDefault
TValueUnconstrainedRequired
TFieldAnyNodeValidatorNode