static define()
Defines the `ValidationError` instance
ValidationError.define()
ValidationError.define()
Defines the ValidationError
instance with the message built of the given required problem
, fix
and optional id
on the supplied or stored template
.
public static define<Id extends string>(
problem: string,
fix: string,
id?: Id,
template = ValidationError.template
): ValidationError<Id> {
return new this(problem, fix, id, template);
}
Generic type variables
A generic type variable constrained by the string
, by default of the value captured from the provided optional id
indicates the identification type of a new ValidationError
instance.
Parameters
Description of the problem of a string
type.
A solution to the given problem
of a string
type.
Optional unique identification to the given problem
of generic type variable Id
.
template =
ValidationError
.template
template =
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 ValidationError.template
.
Return type
The return type is the ValidationError
object that takes generic type variable Id
.
Returns
The return value is a new instance of the ValidationError
with the message built from the given required problem
, fix
and optional id
on the given or stored template
.
Example usage
// Example usage.
import { ValidationError } from '@angular-package/error';
// Returns
// ValidationError: Problem(TE:201): The parameter age is not filled => Fix: Fill the age parameter
ValidationError.define('The parameter age is not filled', 'Fill the age parameter', '(TE:201)');
Last updated
Was this helpful?