dynamic-forms / Interface

CustomValidatorConfig

Custom validator configuration using Angular's public FieldContext API Returns ValidationError | ValidationError[] | null synchronously

Supports two patterns:

  1. Function-based: { type: 'custom', functionName: 'myValidator' }
  2. Expression-based: { type: 'custom', expression: 'fieldValue === formValue.password', kind: 'passwordMismatch' }

Properties

NameTypeDescription
errorParams
Record<string, string> | undefined

Parameters to include in error object for message interpolation (expression-based pattern) Map of parameter names to expressions that will be evaluated in the same context as the validation expression

Example usage

errorParams: { minValue: 'formValue.minValue', maxValue: 'formValue.maxValue' } // Allows message template: "Value must be between {{minValue}} and {{maxValue}}"

expression
string | undefined

JavaScript expression to evaluate (expression-based pattern)

functionName
string | undefined

Name of registered validator function (function-based pattern)

kind
string | undefined

Error kind for expression-based validators - links to validationMessages

params
Record<string, unknown> | undefined

Optional parameters to pass to validator function

type
"custom"

Validator type identifier

when
inherited from BaseValidatorConfig
ConditionalExpression | undefined

Conditional logic for when validator applies