-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (44 loc) · 1.26 KB
/
index.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
'use strict';
var lib = ('undefined'!==typeof global && 'undefined'!==typeof global.require && 'undefined'!==typeof global.require.main && 'undefined'!==typeof global.require.main.frdl)
? global.require.main.frdl
: require('@frdl/functions');
exports = module.exports = extendOwnFormats(extendTyping(
('undefined'===typeof lib.is)
? require('@betafcc/is')
: lib.is
));
function extendOwnFormats(is){
is.oid = {};
is.oid.format = (v) => {
return is.truthy(/^[0-9][0-9\.]+$/.test(v));
};
is.oid.withinFrdlweb = (v) => {
return is.truthy(/^1\.3\.6\.1\.4\.1\.37553(\.[0-9\.]+)?$/.test(v));
};
is.oid.withinWEID = (v) => {
return is.truthy(/^1\.3\.6\.1\.4\.1\.37553\.8(\.[0-9\.]+)?$/.test(v));
};
return is;
}
function isRegExp(test){
var t = Object.prototype.toString.call( test );
return t instanceof RegExp;
}
function extendTyping(is){
is.scalar = (v) => {
return is.oneOf(is.string, is.boolean, is.number, is.integer, is.float)(v);
};
is.scalarOrNull = (v) => {
return is.oneOf(is.scalar, is.null)(v);
};
is.data = (v) => {
return is.oneOf(is.scalarOrNull, is.dict)(v);
};
is.sortable = (v) => {
return is.oneOf(is.iterable, is.string, is.dict)(v);
};
is.regexp = (v) => {
return isRegExp(v);
};
return is;
}