-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.js
More file actions
29 lines (25 loc) · 734 Bytes
/
validator.js
File metadata and controls
29 lines (25 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/** Create Validator for checking the input Values */
const parameterValidator = (queryString) => {
switch (queryString) {
case 'count':
case 'item':
case 'length':
case 'width':
return true;
case 'help':
break;
case 'exit':
return 'exit';
default:
return false;
}
}
const numberRangeValidator = (range) => {
/** Only take the input of integer or decimal number */
let numbers = /^\d+$/;
let decimal = /^[+]?[0-9]+\.[0-9]+$/;
if (range.match(numbers) || range.match(decimal))
return true;
}
/** Exports two functions into main.js */
module.exports = { parameterValidator, numberRangeValidator }