Skip to content

Commit 6e48540

Browse files
committed
feat: show pending validation
1 parent 3b4a4b1 commit 6e48540

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

src/app/registration-form-2/registration-form-2.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ <h1>Version 2: Advanced Validation and Schema Patterns</h1>
1414
[control]="registrationForm.username"
1515
[ariaInvalid]="ariaInvalidState(registrationForm.username)"
1616
/>
17+
@if (registrationForm.username().pending()) {
18+
<small>Checking availability ...</small>
19+
}
1720
<app-form-error [field]="registrationForm.username" />
1821
</label>
1922

src/app/registration-form-2/registration-form-2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class RegistrationForm2 {
130130
protected readonly registrationForm = form(this.registrationModel, formSchema);
131131

132132
protected ariaInvalidState(field: FieldTree<unknown>): boolean | undefined {
133-
return field().touched() ? field().errors().length > 0 : undefined;
133+
return field().touched() && !field().pending() ? field().errors().length > 0 : undefined;
134134
}
135135

136136
protected addEmail(): void {

src/app/registration-form-3/registration-form-3.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ <h1>Version 3: Child Forms and Custom UI Controls</h1>
1414
[control]="registrationForm.username"
1515
[ariaInvalid]="ariaInvalidState(registrationForm.username)"
1616
/>
17+
@if (registrationForm.username().pending()) {
18+
<small>Checking availability ...</small>
19+
}
1720
<app-form-error [field]="registrationForm.username" />
1821
</label>
1922

src/app/registration-form-3/registration-form-3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class RegistrationForm3 {
141141
protected readonly registrationForm = form(this.registrationModel, formSchema);
142142

143143
protected ariaInvalidState(field: FieldTree<unknown>): boolean | undefined {
144-
return field().touched() ? field().errors().length > 0 : undefined;
144+
return field().touched() && !field().pending() ? field().errors().length > 0 : undefined;
145145
}
146146

147147
protected addEmail(): void {

src/app/registration-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class RegistrationService {
2323
return new Promise<boolean>((resolve) => {
2424
setTimeout(() => {
2525
resolve(username === 'johndoe');
26-
}, 500);
26+
}, 2000);
2727
});
2828
}
2929
}

0 commit comments

Comments
 (0)