-
Notifications
You must be signed in to change notification settings - Fork 2
/
validations.js
76 lines (64 loc) · 2.15 KB
/
validations.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* @description Check if current type name type is an array
* @param {{nameType: string, view: string, nameObj: string} | undefined}} hiritageObj
* @returns {boolean}
*/
function isInsideNestedArray(hiritageObj) {
return hiritageObj !== undefined && hiritageObj.nameType === 'array';
}
/**
* @description Check if current type name type is an object
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function currentTypeIsObject(type) {
return type.nameType === 'object';
}
/**
* @description Check if current type name type is an object or array
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function currentTypeIsObjectOrArray(type) {
return ['object', 'array'].includes(type.nameType);
}
/**
* @description Check if current type name type is an array
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function currentTypeIsArray(type) {
return type.nameType === 'array';
}
/**
* @description Verify if hiritageObj is undefined, if true, the type is simple
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function constructStructTypeSimple(hiritageObj) {
return hiritageObj === undefined;
}
/**
* @description Verify if hiritageObj is undefined and nameObj is Undefined, if true, the type is []Undefined
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function constructStructWithArrayOfTypeUndefined(hiritageObj) {
return hiritageObj !== undefined && hiritageObj.nameObj === 'Undefined';
}
/**
* @description Verify if hiritageObj is undefined and nameObj is object, if true, the type is struct with name the key
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function constructStructWithNewStructAux(hiritageObj) {
return hiritageObj !== undefined && hiritageObj.nameType === 'object';
}
/**
* @description verify if
* @param {{nameType: string, view: string, base: string}} type
* @returns {boolean}
*/
function constructStructWithSumType(type) {
return type.length > 0;
}