phone: {
type: int,
minLength: 13,
maxLength: 13,
default: 92,
match:
[
/^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{7}$/,
"Please enter a valid phone number."
]
},
In my application, while registering a new user, they are providing their name, email, image, phone, bio and I want the given phone number to be only integers not a string but it is giving the following error:
[nodemon] app crashed - waiting for file changes before starting...
[nodemon] restarting due to changes...
[nodemon] starting `node server.js`
/home/ahmed/7th Sem/FYP/Dlvr | Dec_31-2022/server/models/userModel.js:31
type: int,
^
ReferenceError: int is not defined
at Object.<anonymous> (/home/ahmed/7th Sem/FYP/Dlvr | Dec_31-2022/server/models/userModel.js:31:15)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/ahmed/7th Sem/FYP/Dlvr | Dec_31-2022/server/controllers/userController.js:2:14)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
[nodemon] app crashed - waiting for file changes before starting...
CodePudding user response:
There is no int
type in TypeScript
. You are probably looking for the number
type. You can read more about the built-in types here: https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#built-in-types .
CodePudding user response:
I think integers are only in 'number' and 'BigInt' format
There's no such data types as 'int' in javascript
For more information about 'Number' data type kindly check this link below
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number