regex - Error: pattern must be a RegExp -
I need to accept a mobile number as the input of the web service, but validating it with the JOI framework The following problem is facing.
Joy says:
Error: Pattern should be a regular expression on Object.exports.assert (/ home / pride / pride-drive / code / nodejsWorkspace / ragchews / Node_modules /joi/node_modules/hoek/lib/index.jsitter24:11) internals.String.regex (low to / home / gaurav / gaurav-drive / code / nodejsWorkspace / ragchews / node_modules / joi / lib / string Js: 107: /home/gaurav/Gaurav-Drive/code/nodejsWorkspace/ragchews/src/validators/userValidator.js:10:40 at 10) on the item & lt; Anonymous & gt; (/home/gaurav/Gaurav-Drive/code/nodejsWorkspace/ragchews/src/validators/userValidator.js:13 jun) on Module._compile (module.js: 456: 26) at Object.Module._extensions..js (Module.js: 474: 10) on module.load (module.js: 356: 32) function.
for validation. Module (. Module: User Profile Validation = Function () {Return {Payload: {UID: JOI. String (). Required (). Alphanumeric () .length (userConfigs.UID_LENGTH), mobile_num: ... Joi.string () required () regex ('^ [0-9] * $') length (userConfigs.RMN_LENGTH) //}} for this man; } ();
I checked regex and seemed to work fine for at least some input, I do not understand why Joe is throwing this error.
Actually, as it records the Joi framework Not that Regex pattern , but a real regex means:, you should use:
Joi.string (). Required (). Regex (/ ^ [0-9] * $ /) [...]
... instead of:
Joi.string () . Required (). Regex ('^ [0-9] * $') [...]
Comments
Post a Comment