src/lib/validate.js   A
last analyzed

Complexity

Total Complexity 9
Complexity/F 1.8

Size

Lines of Code 46
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 0
c 1
b 0
f 1
nc 1
dl 0
loc 46
rs 10
wmc 9
mnd 1
bc 9
fnc 5
bpm 1.8
cpm 1.8
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A validate.js ➔ ??? 0 7 2
1
import {isString, length} from '../string.utils.js';
2
import {_isNumber} from './number';
3
4
const validString = value => {
5
    if(!isString(value)){
6
        throw new Error('[strman] ' + value + ' is not a String.');
7
    }
8
9
    return true;
10
};
11
12
export {validString};
13
14
const validArrayString = array => {
15
16
    array.map((data) => {
17
        if(!isString(data)){
18
            throw new Error('[strman] ' + data + ' is not a String.');
19
        }
20
        return data;
21
    });
22
23
    return true;
24
};
25
26
export {validArrayString};
27
28
const validNumber = value => {
29
    if(!_isNumber(value)){
30
        throw new Error('[strman] ' + value + ' is not a Number.');
31
    }
32
33
    return true;
34
};
35
36
export {validNumber};
37
38
const validCharLength = char => {
39
    if(length(char) === 0){
40
        throw new Error('Char should be length >= 1');
41
    }
42
43
    return true;
44
};
45
46
export {validCharLength};
47