★ Constructor

The `ValidationError` constructor

ValidationError()

Creates the ValidationError instance that represents validation error with the message built of the given described problem, its solution, and optional explicit identification, on the supplied or stored error message template.

validation-error.class.ts
constructor(
  problem: string,
  fix: string,
  id?: Id,
  template = ValidationError.template
) {
  super(problem, fix, id, template);
}

Parameters

problem:string

Description of the problem of a string type.

fix:string

A solution to the given problem of a string type.

id?:Id

Optional unique identification to the given problem of generic type variable Id.

template:string=ValidationError.template

A template of error message with the replaceable {problem}, {fix} and optional {id} tags. By default, the value is equal to the static property template.

Example usage

// Example usage.
import { ValidationError } from '@angular-package/error';

// Returns
// ValidationError: ProblemTE:201: Wrong type => Fix: Change the type
new ValidationError('Wrong type', 'Change the type', 'TE:201');

Last updated