• Genel Bakış
@angular/forms/signals

NgValidationError

constant
kararlıv22.0'den beri

The base class for all built-in, non-custom errors. This class can be used to check if an error is one of the standard kinds, allowing you to switch on the kind to further narrow the type.

API

    
      const NgValidationError: abstract new () => NgValidationError;
    
    

Usage Notes

const f = form(...);
for (const e of form().errors()) {
  if (e instanceof NgValidationError) {
    switch(e.kind) {
      case 'required':
        console.log('This is required!');
        break;
      case 'min':
        console.log(`Must be at least ${e.min}`);
        break;
      ...
    }
  }
}
Detaylara atla