itee-validators 5.3.1 → 5.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +4 -4
- package/builds/itee-validators.cjs.js +20 -18
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.esm.js +9 -7
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.iife.js +10 -8
- package/builds/itee-validators.iife.js.map +1 -1
- package/package.json +19 -19
- package/sources/cores/cores.js +6 -6
- package/sources/cores/numbers/isSafeInteger.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [5.3.5](https://github.com/Itee/itee-validators/compare/v5.3.4...v5.3.5) (2022-02-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **package:** update deps to latest version ([4248576](https://github.com/Itee/itee-validators/commit/424857653ba08ce5eb6483a9afbbf8eba8f46931))
|
|
7
|
+
|
|
8
|
+
## [5.3.4](https://github.com/Itee/itee-validators/compare/v5.3.3...v5.3.4) (2022-02-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **package:** update deps to latest version ([81c59d3](https://github.com/Itee/itee-validators/commit/81c59d3e5d88c65e924689c2b2bdbc67798c5286))
|
|
14
|
+
|
|
15
|
+
## [5.3.3](https://github.com/Itee/itee-validators/compare/v5.3.2...v5.3.3) (2021-07-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **readme:** fix readme tags ([0d8fc2e](https://github.com/Itee/itee-validators/commit/0d8fc2e3c40dd7a3220bb404e68458c9ce167e9b))
|
|
21
|
+
|
|
22
|
+
## [5.3.2](https://github.com/Itee/itee-validators/compare/v5.3.1...v5.3.2) (2021-07-07)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **packagelock:** apply npm audit fix ([cc4a78b](https://github.com/Itee/itee-validators/commit/cc4a78bc0ccabc380931d3508cbf783036c58208))
|
|
28
|
+
|
|
1
29
|
## [5.3.1](https://github.com/Itee/itee-validators/compare/v5.3.0...v5.3.1) (2021-07-07)
|
|
2
30
|
|
|
3
31
|
|
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<br>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<a href="https://www.npmjs.com/package/itee-validators">
|
|
9
|
+
<a href="https://www.npmjs.com/package/itee-validators" target="_blank" rel="noopener noreferrer">
|
|
10
10
|
<img src="https://img.shields.io/npm/v/itee-validators" alt="Current package version">
|
|
11
11
|
</a>
|
|
12
|
-
<a href="https://
|
|
13
|
-
<img src="https://
|
|
12
|
+
<a href="https://github.com/Itee/itee-validators" target="_blank" rel="noopener noreferrer">
|
|
13
|
+
<img src="https://github.com/Itee/itee-validators/actions/workflows/node.js.yml/badge.svg" alt="Itee-Validators CI">
|
|
14
14
|
</a>
|
|
15
|
-
<a href="https://github.com/semantic-release/semantic-release">
|
|
15
|
+
<a href="https://github.com/semantic-release/semantic-release" target="_blank" rel="noopener noreferrer">
|
|
16
16
|
<img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Build status">
|
|
17
17
|
</a>
|
|
18
18
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
console.log('Itee.Validators v5.3.
|
|
1
|
+
console.log('Itee.Validators v5.3.5 - CommonJs')
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -1269,6 +1269,7 @@ function isMinNegative ( data ) {
|
|
|
1269
1269
|
function isMaxSafeInteger ( data ) {
|
|
1270
1270
|
return ( data === Number.MAX_SAFE_INTEGER )
|
|
1271
1271
|
}
|
|
1272
|
+
|
|
1272
1273
|
// Todo: Neg
|
|
1273
1274
|
|
|
1274
1275
|
/**
|
|
@@ -1280,6 +1281,7 @@ function isMaxSafeInteger ( data ) {
|
|
|
1280
1281
|
function isMinSafeInteger ( data ) {
|
|
1281
1282
|
return ( data === Number.MIN_SAFE_INTEGER )
|
|
1282
1283
|
}
|
|
1284
|
+
|
|
1283
1285
|
// Todo: Neg
|
|
1284
1286
|
|
|
1285
1287
|
/**
|
|
@@ -1676,7 +1678,7 @@ class Validator {
|
|
|
1676
1678
|
|
|
1677
1679
|
if ( isNotString( type ) ) { throw new TypeError( `Validator: Expect type to be a string` ) }
|
|
1678
1680
|
if ( isNotFunction( validator ) && isNotObject( validator ) ) { throw new TypeError( `Validator: Expect validator to be an object or a function` ) }
|
|
1679
|
-
if ( isDefined( this.validators[ type ] ) ) { throw new TypeError( `Validator: a validator is already defined for type '${type}'` ) }
|
|
1681
|
+
if ( isDefined( this.validators[ type ] ) ) { throw new TypeError( `Validator: a validator is already defined for type '${ type }'` ) }
|
|
1680
1682
|
|
|
1681
1683
|
this.validators[ type ] = validator;
|
|
1682
1684
|
|
|
@@ -1722,7 +1724,7 @@ class Validator {
|
|
|
1722
1724
|
|
|
1723
1725
|
const validator = this.validators[ type ];
|
|
1724
1726
|
if ( isNotDefined( validator ) ) {
|
|
1725
|
-
throw new TypeError( `Validator: Unable to find schema validation of type '${type}'` )
|
|
1727
|
+
throw new TypeError( `Validator: Unable to find schema validation of type '${ type }'` )
|
|
1726
1728
|
}
|
|
1727
1729
|
|
|
1728
1730
|
let result = true;
|
|
@@ -1737,7 +1739,7 @@ class Validator {
|
|
|
1737
1739
|
|
|
1738
1740
|
const subValidator = validator[ key ];
|
|
1739
1741
|
if ( isNotDefined( subValidator ) ) {
|
|
1740
|
-
throw new TypeError( `Validator: Missing validator for key '${key}' of type '${type}'` )
|
|
1742
|
+
throw new TypeError( `Validator: Missing validator for key '${ key }' of type '${ type }'` )
|
|
1741
1743
|
}
|
|
1742
1744
|
|
|
1743
1745
|
const value = data[ key ];
|
|
@@ -1755,7 +1757,7 @@ class Validator {
|
|
|
1755
1757
|
if ( isDefined( validatorFunction ) ) {
|
|
1756
1758
|
|
|
1757
1759
|
if ( isNotFunction( validatorFunction ) ) {
|
|
1758
|
-
throw new TypeError( `Validator: Invalid validation function for '${key}' with type '${type}'` )
|
|
1760
|
+
throw new TypeError( `Validator: Invalid validation function for '${ key }' with type '${ type }'` )
|
|
1759
1761
|
}
|
|
1760
1762
|
|
|
1761
1763
|
subResult = validatorFunction( value );
|
|
@@ -1768,7 +1770,7 @@ class Validator {
|
|
|
1768
1770
|
|
|
1769
1771
|
if ( subResult === false ) {
|
|
1770
1772
|
|
|
1771
|
-
this.errors.push( `Validator: Invalid property '${key}' of type '${subValidator.type}' with value '${value}' in object of type '${type}'` );
|
|
1773
|
+
this.errors.push( `Validator: Invalid property '${ key }' of type '${ subValidator.type }' with value '${ value }' in object of type '${ type }'` );
|
|
1772
1774
|
result = false;
|
|
1773
1775
|
if ( breakOnError ) {
|
|
1774
1776
|
break
|
|
@@ -1780,7 +1782,7 @@ class Validator {
|
|
|
1780
1782
|
|
|
1781
1783
|
} else {
|
|
1782
1784
|
|
|
1783
|
-
throw new TypeError( `Validator: Unknown validator of type '${type}'` )
|
|
1785
|
+
throw new TypeError( `Validator: Unknown validator of type '${ type }'` )
|
|
1784
1786
|
|
|
1785
1787
|
}
|
|
1786
1788
|
|
|
@@ -2461,7 +2463,7 @@ function isNotTemperature ( data ) {
|
|
|
2461
2463
|
* @returns {boolean} true if path is a block device path, false otherwise
|
|
2462
2464
|
*/
|
|
2463
2465
|
function isBlockDevicePath ( path ) {
|
|
2464
|
-
return fs__default[
|
|
2466
|
+
return fs__default["default"].statSync( path ).isBlockDevice()
|
|
2465
2467
|
}
|
|
2466
2468
|
|
|
2467
2469
|
/**
|
|
@@ -2502,7 +2504,7 @@ function isNotBlockDevicePath ( path ) {
|
|
|
2502
2504
|
* @returns {boolean} true if data is a valid path, false otherwise
|
|
2503
2505
|
*/
|
|
2504
2506
|
function isValidPath ( data ) {
|
|
2505
|
-
return fs__default[
|
|
2507
|
+
return fs__default["default"].existsSync( data )
|
|
2506
2508
|
}
|
|
2507
2509
|
|
|
2508
2510
|
/**
|
|
@@ -2581,7 +2583,7 @@ function isInvalidBlockDevicePath ( data ) {
|
|
|
2581
2583
|
* @returns {boolean} true if path is a character device path, false otherwise
|
|
2582
2584
|
*/
|
|
2583
2585
|
function isCharacterDevicePath ( path ) {
|
|
2584
|
-
return fs__default[
|
|
2586
|
+
return fs__default["default"].statSync( path ).isCharacterDevice()
|
|
2585
2587
|
}
|
|
2586
2588
|
|
|
2587
2589
|
/**
|
|
@@ -2660,7 +2662,7 @@ function isInvalidCharacterDevicePath ( data ) {
|
|
|
2660
2662
|
* @returns {boolean} true if path is a directory path, false otherwise
|
|
2661
2663
|
*/
|
|
2662
2664
|
function isDirectoryPath ( path ) {
|
|
2663
|
-
return fs__default[
|
|
2665
|
+
return fs__default["default"].statSync( path ).isDirectory()
|
|
2664
2666
|
}
|
|
2665
2667
|
|
|
2666
2668
|
/**
|
|
@@ -2701,7 +2703,7 @@ function isNotDirectoryPath ( path ) {
|
|
|
2701
2703
|
* @returns {boolean} true if directory is empty, false otherwise
|
|
2702
2704
|
*/
|
|
2703
2705
|
function isEmptyDirectory ( directoryPath ) {
|
|
2704
|
-
return ( fs__default[
|
|
2706
|
+
return ( fs__default["default"].readdirSync( directoryPath ).length === 0 )
|
|
2705
2707
|
}
|
|
2706
2708
|
|
|
2707
2709
|
/**
|
|
@@ -2780,7 +2782,7 @@ function isInvalidDirectoryPath ( data ) {
|
|
|
2780
2782
|
* @returns {boolean} true if path is a fifo path, false otherwise
|
|
2781
2783
|
*/
|
|
2782
2784
|
function isFIFOPath ( path ) {
|
|
2783
|
-
return fs__default[
|
|
2785
|
+
return fs__default["default"].statSync( path ).isFIFO()
|
|
2784
2786
|
}
|
|
2785
2787
|
|
|
2786
2788
|
/**
|
|
@@ -2863,7 +2865,7 @@ function isInvalidFIFOPath ( data ) {
|
|
|
2863
2865
|
* @returns {boolean} true if file is empty, false otherwise
|
|
2864
2866
|
*/
|
|
2865
2867
|
function isEmptyFile ( filePath, threshold = 0 ) {
|
|
2866
|
-
return ( fs__default[
|
|
2868
|
+
return ( fs__default["default"].statSync( filePath ).size <= threshold )
|
|
2867
2869
|
}
|
|
2868
2870
|
|
|
2869
2871
|
/**
|
|
@@ -2874,7 +2876,7 @@ function isEmptyFile ( filePath, threshold = 0 ) {
|
|
|
2874
2876
|
* @returns {boolean} true if file is not empty, false otherwise
|
|
2875
2877
|
*/
|
|
2876
2878
|
function isNotEmptyFile ( filePath, threshold = 0 ) {
|
|
2877
|
-
return ( fs__default[
|
|
2879
|
+
return ( fs__default["default"].statSync( filePath ).size > threshold )
|
|
2878
2880
|
}
|
|
2879
2881
|
|
|
2880
2882
|
/**
|
|
@@ -2905,7 +2907,7 @@ function isNotEmptyFile ( filePath, threshold = 0 ) {
|
|
|
2905
2907
|
* @returns {boolean} true if path is a file path, false otherwise
|
|
2906
2908
|
*/
|
|
2907
2909
|
function isFilePath ( path ) {
|
|
2908
|
-
return fs__default[
|
|
2910
|
+
return fs__default["default"].statSync( path ).isFile()
|
|
2909
2911
|
}
|
|
2910
2912
|
|
|
2911
2913
|
/**
|
|
@@ -2984,7 +2986,7 @@ function isInvalidFilePath ( data ) {
|
|
|
2984
2986
|
* @returns {boolean} true if path is a socket path, false otherwise
|
|
2985
2987
|
*/
|
|
2986
2988
|
function isSocketPath ( path ) {
|
|
2987
|
-
return fs__default[
|
|
2989
|
+
return fs__default["default"].statSync( path ).isSocket()
|
|
2988
2990
|
}
|
|
2989
2991
|
|
|
2990
2992
|
/**
|
|
@@ -3063,7 +3065,7 @@ function isInvalidSocketPath ( data ) {
|
|
|
3063
3065
|
* @returns {boolean} true if path is a symbolic link path, false otherwise
|
|
3064
3066
|
*/
|
|
3065
3067
|
function isSymbolicLinkPath ( path ) {
|
|
3066
|
-
return fs__default[
|
|
3068
|
+
return fs__default["default"].statSync( path ).isSymbolicLink()
|
|
3067
3069
|
}
|
|
3068
3070
|
|
|
3069
3071
|
/**
|