File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 11"use strict" ;
22
3+ const NUMERIC_PATTERN = / ^ - ? [ 0 - 9 ] \d * ( \. \d + ) ? $ / ;
4+
35module . exports = function checkString ( value , schema ) {
46 if ( typeof value !== "string" ) {
57 return this . makeError ( "string" ) ;
@@ -9,7 +11,6 @@ module.exports = function checkString(value, schema) {
911 alpha: /^[a-zA-Z]+$/
1012 alphaNum: /^[a-zA-Z0-9]+$/
1113 alphaDash: /^[a-zA-Z0-9_\-]+$/
12-
1314 */
1415
1516 const valueLength = value . length ;
@@ -42,5 +43,9 @@ module.exports = function checkString(value, schema) {
4243 return this . makeError ( "stringEnum" , schema . enum ) ;
4344 }
4445
46+ if ( schema . numeric === true && ! RegExp ( / ^ - ? [ 1 - 9 ] \d * ( \. \d + ) ? $ / ) . test ( value ) ) {
47+ return this . makeError ( "stringNumeric" , 'A numeric string' , value ) ;
48+ }
49+
4550 return true ;
4651} ;
You can’t perform that action at this time.
0 commit comments