Skip to content

Commit

Permalink
Merge pull request #295 from dcastil/bugfix/fix-number-validators-acc…
Browse files Browse the repository at this point in the history
…epting-empty-strings

Fix number validators accidentally returning `true` for empty strings
  • Loading branch information
dcastil authored Aug 20, 2023
2 parents 650405d + ac4fc9e commit 91b7d67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export function isArbitraryLength(value: string) {
}

export function isNumber(value: string) {
return !Number.isNaN(Number(value))
return Boolean(value) && !Number.isNaN(Number(value))
}

export function isArbitraryNumber(value: string) {
return getIsArbitraryValue(value, 'number', isNumber)
}

export function isInteger(value: string) {
return Number.isInteger(Number(value))
return Boolean(value) && Number.isInteger(Number(value))
}

export function isPercent(value: string) {
Expand Down

0 comments on commit 91b7d67

Please sign in to comment.