-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(legacy):
InputDateTime
validators not triggered when value chan…
…ge (#9838)
- Loading branch information
Showing
5 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
projects/demo/src/modules/components/input-date-time/examples/7/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<tui-input-date-time [formControl]="control">Choose date and time</tui-input-date-time> | ||
<tui-error | ||
[error]="[] | tuiFieldError | async" | ||
[formControl]="control" | ||
/> | ||
|
||
<p>Form value:</p> | ||
|
||
<pre><code>{{ control.value | json }}</code></pre> |
36 changes: 36 additions & 0 deletions
36
projects/demo/src/modules/components/input-date-time/examples/7/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {AsyncPipe, JsonPipe} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import type {AbstractControl, ValidationErrors, ValidatorFn} from '@angular/forms'; | ||
import {FormControl, ReactiveFormsModule} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiDay} from '@taiga-ui/cdk'; | ||
import {TuiError} from '@taiga-ui/core'; | ||
import {TuiFieldErrorPipe} from '@taiga-ui/kit'; | ||
import {TuiInputDateTimeModule} from '@taiga-ui/legacy'; | ||
|
||
const completeDateTimeValidator: ValidatorFn = ( | ||
control: AbstractControl, | ||
): ValidationErrors | null => | ||
control.value.every(Boolean) ? null : {incompleteDateTime: true}; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
AsyncPipe, | ||
JsonPipe, | ||
ReactiveFormsModule, | ||
TuiError, | ||
TuiFieldErrorPipe, | ||
TuiInputDateTimeModule, | ||
], | ||
templateUrl: './index.html', | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected readonly control = new FormControl( | ||
[new TuiDay(2017, 2, 15), null], | ||
completeDateTimeValidator, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters