Skip to content

Commit

Permalink
fix(valueChanges): don't accept 00 for day & month
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Balet committed Mar 20, 2024
1 parent 43bbd46 commit 5977c68
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-birthday-input",
"version": "17.2.0",
"version": "17.2.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down Expand Up @@ -32,7 +32,7 @@
"@angular-devkit/build-angular": "^17.3.0",
"@angular/cli": "^17.3.0",
"@angular/compiler-cli": "^17.3.0",
"@commitlint/cli": "^19.2.0",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@semantic-release/apm-config": "9.0.1",
"@types/jasmine": "~5.1.4",
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mat-birthday-input/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mat-birthday-input",
"version": "17.2.0",
"version": "17.2.1",
"author": {
"name": "Raphaël Balet",
"email": "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ export class NgxMatBirthdayInputComponent
.get('day')
?.valueChanges.pipe(takeUntil(this._unsubscribe$))
.subscribe((value) => {
if (!this._controlValue(value, 'day')) return
if (value.includes('00')) {
this._controls.day?.setValue(this._formerValues.day)
return
}
if (!this._controlValue(value, 'day')) return

if (+value > 31) this._controls.day?.setValue('31')
else if (typeof value === 'number' && value < 0) this._controls.day?.setValue('01')
Expand All @@ -186,11 +186,11 @@ export class NgxMatBirthdayInputComponent
.get('month')
?.valueChanges.pipe(takeUntil(this._unsubscribe$))
.subscribe((value) => {
if (!this._controlValue(value, 'month')) return
if (value.includes('00')) {
this._controls.month?.setValue(this._formerValues.month)
return
}
if (!this._controlValue(value, 'month')) return

if (+value > 12) this._controls.month?.setValue('12')
else if (typeof value === 'number' && value < 0) this._controls.month?.setValue('01')
Expand Down

0 comments on commit 5977c68

Please sign in to comment.