Skip to main content

ValidatorOptions

Common options supported by built-in validators.

Import

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

When to use it

Use for reusable custom validator configuration. Built-in validators expose their concrete options inline; consult each validator for supported value and context types.

Declaration

type ValidatorOptions<TValue = unknown> = ({
message?: string | (() => string | undefined);
error?: never;
} | {
message?: never;
error?: ValidationResult | ((context: ValidatorContext<TValue>) => ValidationResult);
}) & {
when?: DeferredCondition | ((context: ValidatorContext<TValue>) => boolean);
};

Type parameters

ParameterConstraintDefault
TValueUnconstrainedunknown

Declared members

The declaration above also includes inherited contracts and overloads where applicable.

MemberMeaning
messageHuman-readable message returned with the validation error.
errorCustom error or errors returned instead of the built-in error.
whenReactive predicate deciding whether the validator and its constraint metadata are active. Parameterless conditions have unchecked returns for class self-references; return a boolean. Context-taking conditions retain boolean checking.