Skip to content

Commit 02b0c93

Browse files
update to static suites
1 parent 95b8faf commit 02b0c93

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

package-lock.json

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"lodash": "^4.17.21",
1616
"rxjs": "~7.8.0",
1717
"tslib": "^2.3.0",
18-
"vest": "^5.1.1",
18+
"vest": "^5.2.8",
1919
"zone.js": "~0.13.3"
2020
},
2121
"scripts": {

src/app/template-driven-forms/form.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { AfterViewInit, Directive, inject, Input, OnDestroy, Output } from '@angular/core';
1+
import { Directive, inject, Input, OnDestroy, Output } from '@angular/core';
22
import { AbstractControl, FormGroup, NgForm } from '@angular/forms';
33
import { debounceTime, distinctUntilChanged, map, Subject, takeUntil } from 'rxjs';
4-
import { Suite } from 'vest';
4+
import { StaticSuite } from 'vest';
55

66
@Directive({
77
selector: 'form',
@@ -11,7 +11,7 @@ export class FormDirective<T> implements OnDestroy {
1111
private readonly destroy$$ = new Subject<void>();
1212
public readonly ngForm = inject(NgForm, { self: true });
1313
@Input() public formValue: T | null = null;
14-
@Input() public suite: Suite<string, string, (model: T, field: string) => void> | null = null;
14+
@Input() public suite: StaticSuite<string, string, (model: T, field: string) => void> | null = null;
1515

1616
@Output() public readonly formValueChange = this.ngForm.form.valueChanges.pipe(
1717
debounceTime(0),

src/app/template-driven-forms/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AbstractControl, AsyncValidatorFn, FormGroup, ValidatorFn } from '@angular/forms';
2-
import { Suite, SuiteResult } from 'vest';
2+
import { StaticSuite, SuiteResult } from 'vest';
33
import { set, cloneDeep } from 'lodash';
44
import { Observable } from 'rxjs';
55

@@ -102,7 +102,7 @@ export function getFormGroupField(rootForm: FormGroup, control: AbstractControl)
102102
export function createValidator<T>(
103103
field: string,
104104
model: T,
105-
suite: (model: T, field: string) => SuiteResult<string, string>
105+
suite: StaticSuite<string, string, (model: T, field: string) => void>,
106106
): ValidatorFn {
107107
return (control: AbstractControl) => {
108108
const mod = cloneDeep(model);
@@ -117,7 +117,7 @@ export function createValidator<T>(
117117
export function createAsyncValidator<T>(
118118
field: string,
119119
model: T,
120-
suite: Suite<string, string, (model: T, field: string) => void>,
120+
suite: StaticSuite<string, string, (model: T, field: string) => void>,
121121
): AsyncValidatorFn {
122122
return (control: AbstractControl) => {
123123
const mod = cloneDeep(model);

src/app/validations/purchase.validations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { create, enforce, omitWhen, only, test } from 'vest';
1+
import { enforce, omitWhen, only, staticSuite, test } from 'vest';
22
import { FormModel } from '../models/form.model';
33
import { addressValidations } from './address.validations';
44
import { phonenumberValidations } from './phonenumber.validations';
55
import { SwapiService } from '../swapi.service';
66
import { fromEvent, lastValueFrom, takeUntil } from 'rxjs';
77

88
export const createPurchaseValidationSuite = (swapiService: SwapiService) => {
9-
return create(
9+
return staticSuite(
1010
(model: FormModel, field: string) => {
1111
only(field);
1212

0 commit comments

Comments
 (0)