# Generic type variables

## `ValidationError<`<mark style="color:green;background-color:green;">`Id`</mark>`>`

#### <mark style="color:green;">`Id`</mark>`extends`[<mark style="color:green;">`string`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#string)

​A generic type variable constrained by the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), by default of the value **captured** from the provided [`id`](https://docs.angular-package.dev/error/constructor#id-id) indicates the [identification](https://docs.angular-package.dev/error/getting-started/basic-concepts#unique-identification) type of a new [`ValidationError`](https://docs.angular-package.dev/error/validationerror) instance.

{% code title="validation-error.class.ts" %}

```typescript
class ValidationError<
  Id extends string  // <--- Declare generic type variable Id.
> extends Error {
  ...
  constructor(
    problem: string,
    fix: string,
    id?: Id,   // <--- Capture generic type variable Id.
    template = ValidationError.template
  ) { ... }
  ...
}
```

{% endcode %}
