Skip to content

Commit bc8e965

Browse files
docs(README.md): fix.
1 parent 1787a1f commit bc8e965

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ Manages an [`Error`][js-error] of validation.
146146
| ValidationError.prototype. | Description |
147147
| :------------------------------------------ | :---------- |
148148
| [`fix: string`][error-property-fix] | A possible solution to the described [`problem`][error-property-problem] of validation that is guarded by a [`string`][js-string] type. |
149-
| [`message: string`][error-property-message] | A validation error message guarded by a [`string`][js-string] type that can be built with the [`problem`][error-property-problem] and [`fix`][error-property-fix] of [`ValidationError`](#validationerror) by the [`throw()`][error-method-throw] and [`setMessage()`][error-method-setmessage] method. |
149+
| [`message: string`][error-property-message] | A validation error message guarded by a [`string`][js-string] type that can be built with the [`problem`][error-property-problem] and [`fix`][error-property-fix] of [`ValidationError`](#validationerror) on the [`template`][error-property-template] by the [`throw()`][error-method-throw] and [`setMessage()`][error-method-setmessage] method. |
150150
| [`name: string`][error-property-name] | Error name of a [`string`][js-string] type that is being thrown. |
151-
| [`problem: string`][error-property-problem] | Description of a validation problem guarded by a [`string`][js-string] type. |
151+
| [`problem: string`][error-property-problem] | Description of a validation [`problem`][error-property-problem] guarded by a [`string`][js-string] type. |
152152

153153
[error-property-fix]: #validationerrorprototypefix
154154
[error-property-message]: #validationerrorprototypemessage
@@ -173,7 +173,7 @@ Manages an [`Error`][js-error] of validation.
173173
| :---------------------------------------------- | :---------- |
174174
| [`setFix()`][error-method-setfix] | Sets the fix a possible solution to the described [`problem`][error-property-problem]. |
175175
| [`setMessage()`][error-method-setmessage] | Sets the validation error message of a [`string`][js-string] type from the provided `message` of the [`ErrorMessage`](#errormessage) interface. |
176-
| [`setProblem()`][error-method-setproblem] | Sets description problem of a [`ValidationError`](#validationerror). |
176+
| [`setProblem()`][error-method-setproblem] | Sets description problem of a validation. |
177177
| [`setTemplate()`][error-method-settemplate] | Sets the template of validation error message. |
178178
| [`throw()`][error-method-throw] | Throws an error of [`ValidationError`](#validationerror) with actual settings. |
179179
| [`updateMessage()`][error-method-updatemessage] | Updates the message with a stored [`fix`][error-property-fix], [`problem`][error-property-problem], and [`template`][error-property-template]. |
@@ -195,7 +195,7 @@ Manages an [`Error`][js-error] of validation.
195195

196196
![update]
197197

198-
**`2.0.0`:** Uses static private property `#template` and guards the value with private static method `#guardTemplate()` to be `string` type that contains `[fix]` and `[problem]` words.
198+
**`2.0.0`:** Uses static private property `#template` and guards the value with private static method `#guardTemplate()` to be [`string`][js-string] type that contains `[fix]` and `[problem]` words.
199199

200200
A template of the error message guarded by [`string`][js-string] type with the replaceable `[problem]` and `[fix]` words. By default, it's set to `Problem: [problem] => Fix: [fix]`. It can be set directly or by the [`setTemplate()`][error-method-settemplate] and [`setMessage()`][error-method-setmessage] method. The value is being checked against the existence of `[problem]` and `[fix]` words.
201201

@@ -239,7 +239,7 @@ public set fix(value: string) {
239239

240240
![update]
241241

242-
**`2.0.0`:** Uses inherited from `Error` property and guards the value to be a [`string`][js-string] type.
242+
**`2.0.0`:** Uses inherited from [`Error`][js-error] property and guards the value to be a [`string`][js-string] type.
243243

244244
A validation error message guarded by a [`string`][js-string] type that can be build from the [`problem`][error-property-problem] and [`fix`][error-property-fix] of [`ValidationError`](#validationerror) on the [`template`][error-property-template]. It can be set directly or by the [`throw()`][error-method-throw] and [`setMessage()`][error-method-setmessage] method.
245245

@@ -672,7 +672,7 @@ console.log(validationError.message);
672672

673673
![new]
674674

675-
Sets description [`problem`][error-property-problem] of a validation error.
675+
Sets description [`problem`][error-property-problem] of a validation.
676676

677677
```typescript
678678
public setProblem(
@@ -690,8 +690,8 @@ public setProblem(
690690

691691
| Name: type | Description |
692692
| :------------------------------------------- | :---------- |
693-
| `fix: string` | A possible solution to the described [`problem`][error-property-problem] guarded by a [`string`][js-string] type. |
694-
| `callback?: ResultCallback<CallbackPayload>` | An optional callback function of [`ResultCallback`][package-callback-resultcallback] type to handle the check whether the provided `fix` is a [`string`][js-string]. By default, it uses an internal callback under the `'setProblem'` name, which can be initially set by the optional `callback` parameter that gives access to the internal instance of [`Callback`][callback-github-readme]. |
693+
| `problem: string` | Description of a validation [`problem`][error-property-problem] guarded by a [`string`][js-string] type. |
694+
| `callback?: ResultCallback<CallbackPayload>` | An optional callback function of [`ResultCallback`][package-callback-resultcallback] type to handle the check whether the provided `problem` is a [`string`][js-string]. By default, it uses an internal callback under the `'setProblem'` name, which can be initially set by the optional `callback` parameter that gives access to the internal instance of [`Callback`][callback-github-readme]. |
695695

696696
**Returns:**
697697

@@ -856,6 +856,26 @@ const validationError = new ValidationError({ fix, problem, template });
856856
validationError.throw();
857857
```
858858

859+
```typescript
860+
// Example usage.
861+
import { ValidationError } from '@angular-package/error';
862+
863+
// Define a fix.
864+
const fix = 'There is no solution to the described problem.';
865+
866+
// Define a problem.
867+
const problem = 'The problem has no solution.';
868+
869+
// Define a template.
870+
const template = 'PROBLEM: [problem] FIX: [fix]';
871+
872+
// Initialize an instance.
873+
const validationError = new ValidationError();
874+
875+
// Throw an error with message.
876+
validationError.throw({ fix, problem, template });
877+
```
878+
859879
<br>
860880

861881
#### `ValidationError.prototype.updateMessage()`
@@ -990,14 +1010,14 @@ export interface ErrorMessage {
9901010
**Properties:**
9911011

9921012
**`fix: string`**
993-
Possible solution to the described problem of a [`string`][js-string] type.
1013+
A possible solution to the described problem of a [`string`][js-string] type.
9941014

9951015
**`problem: string`**
9961016
Description of validation problem of a [`string`][js-string] type.
9971017

9981018
**`template?: string`**
9991019
![new]
1000-
An optional message template of a [`string`][js-string] type.
1020+
An optional error message template of a [`string`][js-string] type.
10011021

10021022
<br>
10031023

0 commit comments

Comments
 (0)