Skip to main content

ValidatorSource

One validator or a readonly list in which null and undefined represent no validator.

Import

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

When to use it

Use for inputs accepting declaration validator sources. Both parameterless and context-taking declaration callbacks have unchecked returns. The context and node model remain typed.

The internal DeclarationValidator<TValue, TField> signature is (context: ValidatorContext<TValue, ValidatorApi<TValue>, TField>) => any.

Supported results remain typed contracts

The any return avoids circular initializer inference; it does not expand valid runtime results. Return ValidationResult for errors/messages/success, or ComposableValidationResult<TValue, TField> for synchronous composition. Annotate that return or use a context-taking validator() helper for checked authoring. Returned inline callbacks need such a checked context. See the full result contract.

Declaration

type ValidatorSource<TValue, TField extends AnyNode = ValidatorNode> = DeclarationValidator<TValue, TField> | DeferredValidator | readonly [
validator?: DeferredValidator | DeclarationValidator<TValue, TField> | ValidationSuccess,
...validators: (DeferredValidator | DeclarationValidator<TValue, TField> | ValidationSuccess)[]
];

Type parameters

ParameterConstraintDefault
TValueUnconstrainedRequired
TFieldAnyNodeValidatorNode