dynamic-forms / Variable

DEFAULT_VALIDATION_MESSAGES

Injection token for form-level default validation messages.

Default validation messages act as fallbacks when fields have validation errors but no field-level validationMessages defined.

Like DEFAULT_PROPS, this token is provided ONCE at the DynamicForm level and inherited by all children via Angular's hierarchical injector.

The token provides a Signal to enable reactivity - when config changes, mappers that read the signal inside their computed() will automatically update.

Presentation

const DEFAULT_VALIDATION_MESSAGES: InjectionToken<
  Signal<ValidationMessages | undefined>
>;

Example usage

// In a mapper or component
const defaultMessagesSignal = inject(DEFAULT_VALIDATION_MESSAGES);

return computed(() => {
  const defaultMessages = defaultMessagesSignal?.();  // Read inside computed for reactivity
  const message = defaultMessages?.required ?? 'Field is required';
  // ...
});