File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
src/validation/drivers/validators Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " strontium" ,
3
- "version" : " 2.6.1 " ,
3
+ "version" : " 2.6.2 " ,
4
4
"description" : " Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects." ,
5
5
"main" : " lib/src/index.js" ,
6
6
"types" : " lib/src/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
import { ValidationError } from "../../../errors/http/ValidationError"
2
2
3
3
export const isNumber = ( input ?: unknown ) : number => {
4
- if ( typeof input === "number" ) {
4
+ if ( typeof input === "number" && ! isNaN ( input ) ) {
5
5
return input
6
6
}
7
7
8
+ if ( typeof input === "string" ) {
9
+ let parsedNumber = Number ( input )
10
+
11
+ if ( ! isNaN ( parsedNumber ) ) {
12
+ return parsedNumber
13
+ }
14
+ }
15
+
8
16
throw new ValidationError (
9
17
"IS_NUMBER" ,
10
18
"Value not a number" ,
You can’t perform that action at this time.
0 commit comments