Add documentation to the helpers module.
This commit is contained in:
@@ -63,6 +63,13 @@
|
||||
<code>src/app/_helpers/custom.validator.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Provides methods to perform custom validation to form inputs.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
@@ -131,14 +138,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="4"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:4</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="13"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:13</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Sets errors to the confirm password input field if it does not match with the value in the password input field.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -148,6 +157,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -162,6 +172,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The control object of the form being validated.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -203,14 +219,16 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="12"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:12</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="28"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:28</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Sets errors to a form field if it does not match with the regular expression given.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -220,6 +238,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -234,6 +253,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The regular expression to match with the form field.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
@@ -246,6 +271,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Defines the map of errors to return from failed validation checks.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -257,7 +288,8 @@
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>The map of errors returned from failed validation checks.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -275,7 +307,15 @@
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {AbstractControl, ValidationErrors} from '@angular/forms';
|
||||
|
||||
/**
|
||||
* Provides methods to perform custom validation to form inputs.
|
||||
*/
|
||||
export class CustomValidator {
|
||||
/**
|
||||
* Sets errors to the confirm password input field if it does not match with the value in the password input field.
|
||||
*
|
||||
* @param control - The control object of the form being validated.
|
||||
*/
|
||||
static passwordMatchValidator(control: AbstractControl): void {
|
||||
const password: string = control.get('password').value;
|
||||
const confirmPassword: string = control.get('confirmPassword').value;
|
||||
@@ -284,6 +324,13 @@ export class CustomValidator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets errors to a form field if it does not match with the regular expression given.
|
||||
*
|
||||
* @param regex - The regular expression to match with the form field.
|
||||
* @param error - Defines the map of errors to return from failed validation checks.
|
||||
* @returns The map of errors returned from failed validation checks.
|
||||
*/
|
||||
static patternValidator(regex: RegExp, error: ValidationErrors): ValidationErrors | null {
|
||||
return (control: AbstractControl): { [key: string]: any } => {
|
||||
if (!control.value) {
|
||||
|
||||
Reference in New Issue
Block a user