Skip to content

Commit

Permalink
(fix) KH-180: Fixed the min and max validator for number inputs to va…
Browse files Browse the repository at this point in the history
…lidate value 0 (#52)

* Fixed the min and max validator for number inputs to validate value 0

* Removed the console.logs
  • Loading branch information
vasharma05 authored Jun 7, 2023
1 parent 3abb968 commit 381c153
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export class MaxValidator {
return null;
}

if (control.value && control.value.length !== 0) {
// Case 1: control.value is a number
// all the numbers should be passed for validation
// Case 2: control.value is not a number:
// if its empty string or null or undefined it will return false else it will pass through for validation
if (typeof control.value === 'number' || control.value) {
const v: number = control.value;
return v <= max
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export class MinValidator {
if (control.hidden) {
return null;
}
if (control.value && control.value.length !== 0) {

// Case 1: control.value is a number
// all the numbers should be passed for validation
// Case 2: control.value is not a number:
// if its empty string or null or undefined it will return false else it will pass through for validation
if (typeof control.value === 'number' || control.value) {
const v: number = control.value;
return v >= min
? null
Expand Down

0 comments on commit 381c153

Please sign in to comment.