Const

DEFAULT_VALIDATION_MESSAGES

@ng-forge/dynamic-forms

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.

Signature

const DEFAULT_VALIDATION_MESSAGES: InjectionToken<Signal<ValidationMessages>>

Examples

// 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';
  // ...
});