Skip to content

Commit

Permalink
fix (validator): Check if a value is a number
Browse files Browse the repository at this point in the history
  • Loading branch information
nbayramberdiyev committed Nov 3, 2021
1 parent dde0173 commit 5985ef7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions snippets/validator/check-if-a-value-is-a-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ category: Validator

**JavaScript version**

```js
const isNumber = (value) => !isNaN(parseFloat(value)) && isFinite(value);
```

**TypeScript version**

```js
const isNumber = (value: any): number => !isNaN(parseFloat(value)) && isFinite(value);
```

0 comments on commit 5985ef7

Please sign in to comment.