itee-validators 5.3.9 → 5.4.0
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 +15 -0
- package/builds/itee-validators.cjs.js +278 -277
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.cjs.min.js +144 -144
- package/builds/itee-validators.esm.js +210 -205
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.esm.min.js +97 -97
- package/builds/itee-validators.iife.js +210 -205
- package/builds/itee-validators.iife.js.map +1 -1
- package/builds/itee-validators.iife.min.js +115 -115
- package/package.json +3 -1
- package/sources/cores/arrays/isArray.js +4 -4
- package/sources/cores/arrays/isArrayOfArray.js +2 -2
- package/sources/cores/arrays/isArrayOfBoolean.js +2 -2
- package/sources/cores/arrays/isArrayOfFunction.js +2 -2
- package/sources/cores/arrays/isArrayOfMultiElement.js +1 -1
- package/sources/cores/arrays/isArrayOfNull.js +2 -2
- package/sources/cores/arrays/isArrayOfNumber.js +2 -2
- package/sources/cores/arrays/isArrayOfObject.js +2 -2
- package/sources/cores/arrays/isArrayOfSingleElement.js +1 -1
- package/sources/cores/arrays/isArrayOfString.js +3 -3
- package/sources/cores/arrays/isArrayOfUndefined.js +2 -2
- package/sources/cores/arrays/isEmptyArray.js +2 -2
- package/sources/cores/booleans/isBoolean.js +4 -4
- package/sources/cores/booleans/isTrue.js +2 -2
- package/sources/cores/cores.js +91 -91
- package/sources/cores/functions/isFunction.js +2 -2
- package/sources/cores/numbers/isInfinite.js +13 -19
- package/sources/cores/numbers/isMax.js +2 -2
- package/sources/cores/numbers/isMin.js +2 -2
- package/sources/cores/numbers/isNumber.js +15 -15
- package/sources/cores/numbers/isSafeInteger.js +2 -2
- package/sources/cores/numbers/isZero.js +3 -3
- package/sources/cores/objects/isEmptyObject.js +2 -2
- package/sources/cores/objects/isObject.js +2 -2
- package/sources/cores/strings/isBlankString.js +2 -2
- package/sources/cores/strings/isEmptyString.js +2 -2
- package/sources/cores/strings/isString.js +7 -7
- package/sources/cores/symbols/isSymbol.js +2 -2
- package/sources/cores/tests/isTestUnitGenerator.js +10 -10
- package/sources/cores/typed-arrays/isArrayBuffer.js +2 -2
- package/sources/cores/typed-arrays/isBigInt64Array.js +2 -2
- package/sources/cores/typed-arrays/isBigUint64Array.js +2 -2
- package/sources/cores/typed-arrays/isFloat32Array.js +2 -2
- package/sources/cores/typed-arrays/isFloat64Array.js +2 -2
- package/sources/cores/typed-arrays/isInt16Array.js +2 -2
- package/sources/cores/typed-arrays/isInt32Array.js +2 -2
- package/sources/cores/typed-arrays/isInt8Array.js +2 -2
- package/sources/cores/typed-arrays/isUint16Array.js +2 -2
- package/sources/cores/typed-arrays/isUint32Array.js +2 -2
- package/sources/cores/typed-arrays/isUint8Array.js +2 -2
- package/sources/cores/typed-arrays/isUint8ClampedArray.js +2 -2
- package/sources/cores/voids/isDefined.js +2 -2
- package/sources/cores/voids/isEmpty.js +2 -2
- package/sources/cores/voids/isNull.js +3 -3
- package/sources/cores/voids/isUndefined.js +2 -2
- package/sources/dom/isEventTarget.js +2 -2
- package/sources/file-system/block-devices/isBlockDevicePath.js +9 -9
- package/sources/file-system/block-devices/isValidBlockDevicePath.js +2 -2
- package/sources/file-system/character-devices/isCharacterDevicePath.js +9 -9
- package/sources/file-system/character-devices/isValidCharacterDevicePath.js +2 -2
- package/sources/file-system/directories/isDirectoryPath.js +9 -9
- package/sources/file-system/directories/isEmptyDirectory.js +4 -4
- package/sources/file-system/directories/isValidDirectoryPath.js +2 -2
- package/sources/file-system/fifo-pipes/isFIFOPath.js +9 -9
- package/sources/file-system/fifo-pipes/isValidFIFOPath.js +2 -2
- package/sources/file-system/files/isEmptyFile.js +9 -9
- package/sources/file-system/files/isFilePath.js +9 -9
- package/sources/file-system/files/isValidFilePath.js +2 -2
- package/sources/file-system/paths/isValidPath.js +4 -4
- package/sources/file-system/sockets/isSocketPath.js +9 -9
- package/sources/file-system/sockets/isValidSocketPath.js +2 -2
- package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +9 -9
- package/sources/file-system/symbolic-links/isValidSymbolicLinkPath.js +2 -2
- package/sources/itee-validators.js +1 -14
- package/sources/physics/temperatures/isCelsius.js +2 -2
- package/sources/physics/temperatures/isFahrenheit.js +2 -2
- package/sources/physics/temperatures/isKelvin.js +2 -2
- package/sources/physics/temperatures/isTemperature.js +2 -2
|
@@ -153,7 +153,7 @@ function s(r){return null!=r}function c(r){return null==r}
|
|
|
153
153
|
* //...
|
|
154
154
|
* }
|
|
155
155
|
*
|
|
156
|
-
*/function l(r){return
|
|
156
|
+
*/function l(r){return r===Number.NEGATIVE_INFINITY}function y(r){return r===Number.POSITIVE_INFINITY}function N(r){return l(r)||y(r)}function A(r){return 0===r&&1/r===Number.POSITIVE_INFINITY}
|
|
157
157
|
/**
|
|
158
158
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
159
159
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -171,7 +171,7 @@ function s(r){return null!=r}function c(r){return null==r}
|
|
|
171
171
|
* }
|
|
172
172
|
*
|
|
173
173
|
*/
|
|
174
|
-
function
|
|
174
|
+
function g(r){return!c(r)&&r.constructor===Number}function h(r){return!g(r)}function d(r){return Number.isInteger(r)}function I(r){return!h(r)&&(!Number.isNaN(r)&&(!N(r)&&r%1!=0))}
|
|
175
175
|
/**
|
|
176
176
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
177
177
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -189,7 +189,7 @@ function A(r){return!c(r)&&r.constructor===Number}function g(r){return!A(r)}func
|
|
|
189
189
|
* }
|
|
190
190
|
*
|
|
191
191
|
*/
|
|
192
|
-
function
|
|
192
|
+
function p(r){return!c(r)&&r.constructor===Object}function b(r){return!p(r)}
|
|
193
193
|
/**
|
|
194
194
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
195
195
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -224,7 +224,7 @@ function I(r){return!c(r)&&r.constructor===Object}function b(r){return!I(r)}
|
|
|
224
224
|
* }
|
|
225
225
|
*
|
|
226
226
|
*/
|
|
227
|
-
function
|
|
227
|
+
function E(r){return"string"==typeof r||r instanceof String}function m(r){return!E(r)}
|
|
228
228
|
/**
|
|
229
229
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
230
230
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -241,7 +241,7 @@ function p(r){return"string"==typeof r||r instanceof String}function m(r){return
|
|
|
241
241
|
* //...
|
|
242
242
|
* }
|
|
243
243
|
*
|
|
244
|
-
*/function
|
|
244
|
+
*/function O(r){return void 0!==r}
|
|
245
245
|
/**
|
|
246
246
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
247
247
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -276,7 +276,7 @@ function p(r){return"string"==typeof r||r instanceof String}function m(r){return
|
|
|
276
276
|
* }
|
|
277
277
|
*
|
|
278
278
|
*/
|
|
279
|
-
function
|
|
279
|
+
function v(r){if(b(r))return!1;if(0===r.length)return!0;for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}
|
|
280
280
|
/**
|
|
281
281
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
282
282
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -294,7 +294,7 @@ function O(r){if(b(r))return!1;if(0===r.length)return!0;for(let t in r)if(Object
|
|
|
294
294
|
* }
|
|
295
295
|
*
|
|
296
296
|
*/
|
|
297
|
-
function
|
|
297
|
+
function U(r){return!m(r)&&0===r.length}
|
|
298
298
|
/**
|
|
299
299
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
300
300
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -312,7 +312,7 @@ function v(r){return!m(r)&&0===r.length}
|
|
|
312
312
|
* }
|
|
313
313
|
*
|
|
314
314
|
*/
|
|
315
|
-
function
|
|
315
|
+
function S(r){return!m(r)&&(!U(r)&&!/\S/.test(r))}
|
|
316
316
|
/**
|
|
317
317
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
318
318
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -348,7 +348,7 @@ function F(r){return"symbol"==typeof r}
|
|
|
348
348
|
* }
|
|
349
349
|
*
|
|
350
350
|
*/
|
|
351
|
-
function
|
|
351
|
+
function T(r){return!c(r)&&(!!U(r)||(!!i(r)||!!v(r)))}
|
|
352
352
|
/**
|
|
353
353
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
354
354
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -363,118 +363,118 @@ function S(r){return!c(r)&&(!!v(r)||(!!i(r)||!!O(r)))}
|
|
|
363
363
|
// Usefull when a simple data structure is used multiple times
|
|
364
364
|
validator.add( 'ColorType', color => {
|
|
365
365
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
const r = color.r
|
|
367
|
+
if ( color.r === undefined || Itee.Validators.isNotNumber( r ) ) {
|
|
368
|
+
return false
|
|
369
|
+
}
|
|
370
370
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
371
|
+
const g = color.g
|
|
372
|
+
if ( color.g === undefined || Itee.Validators.isNotNumber( g ) ) {
|
|
373
|
+
return false
|
|
374
|
+
}
|
|
375
375
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
const b = color.b
|
|
377
|
+
if ( color.b === undefined || Itee.Validators.isNotNumber( b ) ) {
|
|
378
|
+
return false
|
|
379
|
+
}
|
|
380
380
|
|
|
381
|
-
|
|
382
|
-
|
|
381
|
+
return true
|
|
382
|
+
} )
|
|
383
383
|
|
|
384
384
|
// Using schema composition
|
|
385
385
|
// Usefull for design validation schema faster and based on previous declared validation types
|
|
386
386
|
validator.add( 'Range_0_255', ( value ) => {
|
|
387
387
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
if ( Itee.Validators.isNotNumber( value ) ) {
|
|
389
|
+
return false
|
|
390
|
+
}
|
|
391
391
|
|
|
392
|
-
|
|
392
|
+
return !(value <= 0 || value > 255)
|
|
393
393
|
|
|
394
|
-
|
|
394
|
+
} )
|
|
395
395
|
|
|
396
396
|
validator.add( 'ColorSchema', {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
397
|
+
r: {
|
|
398
|
+
required: true,
|
|
399
|
+
type: 'Range_0_255'
|
|
400
|
+
},
|
|
401
|
+
g: {
|
|
402
|
+
required: true,
|
|
403
|
+
type: 'Range_0_255'
|
|
404
|
+
},
|
|
405
|
+
b: {
|
|
406
|
+
required: true,
|
|
407
|
+
type: 'Range_0_255'
|
|
408
|
+
}
|
|
409
|
+
} )
|
|
410
410
|
|
|
411
411
|
validator.add( 'ColorStructure', {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
412
|
+
color_from_type: {
|
|
413
|
+
type: 'ColorType'
|
|
414
|
+
},
|
|
415
|
+
col_from_schema: {
|
|
416
|
+
type: 'ColorSchema'
|
|
417
|
+
},
|
|
418
|
+
col_from_fn: {
|
|
419
|
+
// Inner function
|
|
420
|
+
// Usefull for specific validation requirement that cannot match other previous validation schema or type
|
|
421
|
+
fn: function ColorValidator ( color ) {
|
|
422
422
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
423
|
+
const r = color.r
|
|
424
|
+
if ( color.r === undefined || Itee.Validators.isNotNumber( r ) ) {
|
|
425
|
+
return false
|
|
426
|
+
}
|
|
427
427
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
const g = color.g
|
|
429
|
+
if ( color.g === undefined || Itee.Validators.isNotNumber( g ) ) {
|
|
430
|
+
return false
|
|
431
|
+
}
|
|
432
432
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
433
|
+
const b = color.b
|
|
434
|
+
if ( color.b === undefined || Itee.Validators.isNotNumber( b ) ) {
|
|
435
|
+
return false
|
|
436
|
+
}
|
|
437
437
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
438
|
+
return true
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
} )
|
|
442
442
|
|
|
443
443
|
// The data to validate
|
|
444
444
|
const colorStruct = {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
445
|
+
color_from_type: {
|
|
446
|
+
r: 0,
|
|
447
|
+
g: 1,
|
|
448
|
+
b: 2
|
|
449
|
+
},
|
|
450
|
+
col_from_schema: {
|
|
451
|
+
r: 10,
|
|
452
|
+
g: 20,
|
|
453
|
+
b: 30
|
|
454
|
+
},
|
|
455
|
+
col_from_fn: {
|
|
456
|
+
r: 0,
|
|
457
|
+
g: 127,
|
|
458
|
+
b: 255
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
461
|
|
|
462
462
|
// Execute
|
|
463
463
|
|
|
464
464
|
try {
|
|
465
465
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
466
|
+
if ( validator.check( colorStruct, 'ColorStructure' ) ) {
|
|
467
|
+
alert( 'ColorStructure is valid !' )
|
|
468
|
+
} else {
|
|
469
|
+
alert( validator.errors )
|
|
470
|
+
}
|
|
471
471
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
} catch ( err ) {
|
|
473
|
+
alert( err )
|
|
474
|
+
}
|
|
475
475
|
*
|
|
476
476
|
*/
|
|
477
|
-
class
|
|
477
|
+
class V{constructor(){this.validators={Boolean:e,Number:g,Integer:d,Float:I,Array:t,String:E,Object:p,Symbol:F,Function:o},this.errors=[]}add(r,t){if(m(r))throw new TypeError("Validator: Expect type to be a string");if(f(t)&&b(t))throw new TypeError("Validator: Expect validator to be an object or a function");if(s(this.validators[r]))throw new TypeError(`Validator: a validator is already defined for type '${r}'`);this.validators[r]=t}remove(r){delete this.validators[r]}getAvalaibleTypes(){const r=[];for(let t in this.validators)r.push(t);return r}check(r,t,n=!0){const i=this.validators[t];if(c(i))throw new TypeError(`Validator: Unable to find schema validation of type '${t}'`);let e=!0;if(o(i))e=i(r);else{if(!p(i))throw new TypeError(`Validator: Unknown validator of type '${t}'`);{let u=!0;for(let o in i){const a=i[o];if(c(a))throw new TypeError(`Validator: Missing validator for key '${o}' of type '${t}'`);const l=r[o],y=a.required;if(c(l)){if(!y)continue;u=!1}let N=a.fn;if(s(N)){if(f(N))throw new TypeError(`Validator: Invalid validation function for '${o}' with type '${t}'`);u=N(l)}else u=this.check(l,a.type,n);if(!1===u&&(this.errors.push(`Validator: Invalid property '${o}' of type '${a.type}' with value '${l}' in object of type '${t}'`),e=!1,n))break}}}return e}}
|
|
478
478
|
/**
|
|
479
479
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
480
480
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -492,7 +492,7 @@ class T{constructor(){this.validators={Boolean:e,Number:A,Integer:h,Float:d,Arra
|
|
|
492
492
|
* }
|
|
493
493
|
*
|
|
494
494
|
*/
|
|
495
|
-
function
|
|
495
|
+
function _(r){return r instanceof ArrayBuffer}
|
|
496
496
|
/**
|
|
497
497
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
498
498
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -510,7 +510,7 @@ function V(r){return r instanceof ArrayBuffer}
|
|
|
510
510
|
* }
|
|
511
511
|
*
|
|
512
512
|
*/
|
|
513
|
-
function
|
|
513
|
+
function w(r){return r instanceof BigInt64Array}
|
|
514
514
|
/**
|
|
515
515
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
516
516
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -528,7 +528,7 @@ function _(r){return r instanceof BigInt64Array}
|
|
|
528
528
|
* }
|
|
529
529
|
*
|
|
530
530
|
*/
|
|
531
|
-
function
|
|
531
|
+
function B(r){return r instanceof BigUint64Array}
|
|
532
532
|
/**
|
|
533
533
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
534
534
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -546,7 +546,7 @@ function w(r){return r instanceof BigUint64Array}
|
|
|
546
546
|
* }
|
|
547
547
|
*
|
|
548
548
|
*/
|
|
549
|
-
function
|
|
549
|
+
function M(r){return r instanceof Float32Array}
|
|
550
550
|
/**
|
|
551
551
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
552
552
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -564,7 +564,7 @@ function B(r){return r instanceof Float32Array}
|
|
|
564
564
|
* }
|
|
565
565
|
*
|
|
566
566
|
*/
|
|
567
|
-
function
|
|
567
|
+
function j(r){return r instanceof Float64Array}
|
|
568
568
|
/**
|
|
569
569
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
570
570
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -582,7 +582,7 @@ function M(r){return r instanceof Float64Array}
|
|
|
582
582
|
* }
|
|
583
583
|
*
|
|
584
584
|
*/
|
|
585
|
-
function
|
|
585
|
+
function $(r){return r instanceof Int16Array}
|
|
586
586
|
/**
|
|
587
587
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
588
588
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -600,7 +600,7 @@ function j(r){return r instanceof Int16Array}
|
|
|
600
600
|
* }
|
|
601
601
|
*
|
|
602
602
|
*/
|
|
603
|
-
function
|
|
603
|
+
function L(r){return r instanceof Int32Array}
|
|
604
604
|
/**
|
|
605
605
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
606
606
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -618,7 +618,7 @@ function $(r){return r instanceof Int32Array}
|
|
|
618
618
|
* }
|
|
619
619
|
*
|
|
620
620
|
*/
|
|
621
|
-
function
|
|
621
|
+
function P(r){return r instanceof Int8Array}
|
|
622
622
|
/**
|
|
623
623
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
624
624
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -636,7 +636,7 @@ function L(r){return r instanceof Int8Array}
|
|
|
636
636
|
* }
|
|
637
637
|
*
|
|
638
638
|
*/
|
|
639
|
-
function
|
|
639
|
+
function k(r){return r instanceof Uint16Array}
|
|
640
640
|
/**
|
|
641
641
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
642
642
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -654,7 +654,7 @@ function P(r){return r instanceof Uint16Array}
|
|
|
654
654
|
* }
|
|
655
655
|
*
|
|
656
656
|
*/
|
|
657
|
-
function
|
|
657
|
+
function C(r){return r instanceof Uint32Array}
|
|
658
658
|
/**
|
|
659
659
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
660
660
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -672,7 +672,7 @@ function k(r){return r instanceof Uint32Array}
|
|
|
672
672
|
* }
|
|
673
673
|
*
|
|
674
674
|
*/
|
|
675
|
-
function
|
|
675
|
+
function R(r){return r instanceof Uint8Array}
|
|
676
676
|
/**
|
|
677
677
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
678
678
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -690,7 +690,7 @@ function C(r){return r instanceof Uint8Array}
|
|
|
690
690
|
* }
|
|
691
691
|
*
|
|
692
692
|
*/
|
|
693
|
-
function
|
|
693
|
+
function Z(r){return r instanceof Uint8ClampedArray}r.Validator=void 0,c(r.Validator)&&(r.Validator=new V);
|
|
694
694
|
/**
|
|
695
695
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
696
696
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -699,7 +699,7 @@ function R(r){return r instanceof Uint8ClampedArray}r.Validator=void 0,c(r.Valid
|
|
|
699
699
|
* @desc Export constants about temperatures
|
|
700
700
|
*
|
|
701
701
|
*/
|
|
702
|
-
const
|
|
702
|
+
const x=4.5e-10,G=-273.14999999955,Y=-459.67;
|
|
703
703
|
/**
|
|
704
704
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
705
705
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -717,7 +717,7 @@ const Z=4.5e-10,x=-273.14999999955,G=-459.67;
|
|
|
717
717
|
* }
|
|
718
718
|
*
|
|
719
719
|
*/
|
|
720
|
-
function
|
|
720
|
+
function K(r){return g(r)&&r>=G}function X(r){return!K(r)}
|
|
721
721
|
/**
|
|
722
722
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
723
723
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -734,7 +734,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
734
734
|
* //...
|
|
735
735
|
* }
|
|
736
736
|
*
|
|
737
|
-
*/function
|
|
737
|
+
*/function D(r){return g(r)&&r>=Y}function H(r){return!D(r)}
|
|
738
738
|
/**
|
|
739
739
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
740
740
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -751,7 +751,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
751
751
|
* //...
|
|
752
752
|
* }
|
|
753
753
|
*
|
|
754
|
-
*/function
|
|
754
|
+
*/function q(r){return g(r)&&r>=x}function z(r){return!q(r)}
|
|
755
755
|
/**
|
|
756
756
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
757
757
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -768,7 +768,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
768
768
|
* //...
|
|
769
769
|
* }
|
|
770
770
|
*
|
|
771
|
-
*/return r.ABSOLUTE_ZERO_CELSIUS=
|
|
771
|
+
*/return r.ABSOLUTE_ZERO_CELSIUS=G,r.ABSOLUTE_ZERO_FAHRENHEIT=Y,r.ABSOLUTE_ZERO_KELVIN=x,r.isArray=t,r.isArrayBuffer=_,r.isArrayOfArray=
|
|
772
772
|
/**
|
|
773
773
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
774
774
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -839,7 +839,7 @@ function(r){return!n(r)&&r.length>1}
|
|
|
839
839
|
* }
|
|
840
840
|
*
|
|
841
841
|
*/
|
|
842
|
-
function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(
|
|
842
|
+
function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(h(r[t]))return!1;return!0},r.isArrayOfObject=function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(b(r[t]))return!1;return!0},r.isArrayOfSingleElement=
|
|
843
843
|
/**
|
|
844
844
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
845
845
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -857,7 +857,7 @@ function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(
|
|
|
857
857
|
* }
|
|
858
858
|
*
|
|
859
859
|
*/
|
|
860
|
-
function(r){return!n(r)&&1===r.length},r.isArrayOfString=function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(m(r[t]))return!1;return!0},r.isArrayOfUndefined=function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(
|
|
860
|
+
function(r){return!n(r)&&1===r.length},r.isArrayOfString=function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(m(r[t]))return!1;return!0},r.isArrayOfUndefined=function(r){if(n(r))return!1;if(i(r))return!1;for(let t=0,n=r.length;t<n;t++)if(O(r[t]))return!1;return!0},r.isBigInt64Array=w,r.isBigUint64Array=B,r.isBlankString=S,r.isBoolean=e,r.isCelsius=K,r.isDefined=s,r.isEmpty=T,r.isEmptyArray=i,r.isEmptyObject=v,r.isEmptyString=U,r.isFahrenheit=D,r.isFalse=function(r){return e(r)&&!1===r}
|
|
861
861
|
/**
|
|
862
862
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
863
863
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -891,7 +891,7 @@ function(r){return!n(r)&&1===r.length},r.isArrayOfString=function(r){if(n(r))ret
|
|
|
891
891
|
* //...
|
|
892
892
|
* }
|
|
893
893
|
*
|
|
894
|
-
*/,r.isFloat=
|
|
894
|
+
*/,r.isFloat=I,r.isFloat32Array=M,r.isFloat64Array=j,r.isFunction=o,r.isInfinite=N,r.isInfiniteNegative=l,r.isInfinitePositive=y,r.isInt16Array=$,r.isInt32Array=L,r.isInt8Array=P,r.isInteger=d,r.isKelvin=q,r.isMaxNegative=function(r){return r===-Number.MAX_VALUE}
|
|
895
895
|
/**
|
|
896
896
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
897
897
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -926,7 +926,7 @@ function(r){return!n(r)&&1===r.length},r.isArrayOfString=function(r){if(n(r))ret
|
|
|
926
926
|
* }
|
|
927
927
|
*
|
|
928
928
|
*/
|
|
929
|
-
function(r){return r===Number.MAX_SAFE_INTEGER},r.isMinNegative=function(r){return r===-Number.MIN_VALUE},r.isMinPositive=function(r){return r===Number.MIN_VALUE},r.isMinSafeInteger=function(r){return r===Number.MIN_SAFE_INTEGER},r.isNaN=function(r){return Number.isNaN(r)},r.isNotArray=n,r.isNotArrayBuffer=function(r){return!
|
|
929
|
+
function(r){return r===Number.MAX_SAFE_INTEGER},r.isMinNegative=function(r){return r===-Number.MIN_VALUE},r.isMinPositive=function(r){return r===Number.MIN_VALUE},r.isMinSafeInteger=function(r){return r===Number.MIN_SAFE_INTEGER},r.isNaN=function(r){return Number.isNaN(r)},r.isNotArray=n,r.isNotArrayBuffer=function(r){return!_(r)},r.isNotArrayOfArray=function(r){if(n(r))return!0;if(i(r))return!0;for(let n=0,i=r.length;n<i;n++)if(t(r[n]))return!1;return!0},r.isNotArrayOfBoolean=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(u(r[t]))return!0;return!1},r.isNotArrayOfFunction=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(f(r[t]))return!0;return!1},r.isNotArrayOfNull=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(a(r[t]))return!0;return!1},r.isNotArrayOfNumber=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(h(r[t]))return!0;return!1},r.isNotArrayOfObject=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(b(r[t]))return!0;return!1},r.isNotArrayOfString=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(m(r[t]))return!0;return!1}
|
|
930
930
|
/**
|
|
931
931
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
932
932
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -943,7 +943,7 @@ function(r){return r===Number.MAX_SAFE_INTEGER},r.isMinNegative=function(r){retu
|
|
|
943
943
|
* //...
|
|
944
944
|
* }
|
|
945
945
|
*
|
|
946
|
-
*/,r.isNotArrayOfUndefined=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(
|
|
946
|
+
*/,r.isNotArrayOfUndefined=function(r){if(n(r))return!0;if(i(r))return!0;for(let t=0,n=r.length;t<n;t++)if(O(r[t]))return!0;return!1}
|
|
947
947
|
/**
|
|
948
948
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
949
949
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -960,4 +960,4 @@ function(r){return r===Number.MAX_SAFE_INTEGER},r.isMinNegative=function(r){retu
|
|
|
960
960
|
* //...
|
|
961
961
|
* }
|
|
962
962
|
*
|
|
963
|
-
*/,r.isNotBigInt64Array=function(r){return!
|
|
963
|
+
*/,r.isNotBigInt64Array=function(r){return!w(r)},r.isNotBigUint64Array=function(r){return!B(r)},r.isNotBlankString=function(r){return!S(r)},r.isNotBoolean=u,r.isNotCelsius=X,r.isNotDefined=c,r.isNotEmpty=function(r){return!T(r)},r.isNotEmptyArray=function(r){return!!n(r)||r.length>0},r.isNotEmptyObject=function(r){return!v(r)},r.isNotEmptyString=function(r){return!U(r)},r.isNotFahrenheit=H,r.isNotFloat32Array=function(r){return!M(r)},r.isNotFloat64Array=function(r){return!j(r)},r.isNotFunction=f,r.isNotInt16Array=function(r){return!$(r)},r.isNotInt32Array=function(r){return!L(r)},r.isNotInt8Array=function(r){return!P(r)},r.isNotKelvin=z,r.isNotNull=a,r.isNotNumber=h,r.isNotObject=b,r.isNotString=m,r.isNotSymbol=function(r){return"symbol"!=typeof r},r.isNotTemperature=function(r){return z(r)&&X(r)&&H(r)},r.isNotUint16Array=function(r){return!k(r)},r.isNotUint32Array=function(r){return!C(r)},r.isNotUint8Array=function(r){return!R(r)},r.isNotUint8ClampedArray=function(r){return!Z(r)},r.isNotUndefined=O,r.isNull=function(r){return null===r},r.isNumber=g,r.isNumberNegative=function(r){return g(r)&&r<0},r.isNumberPositive=function(r){return!h(r)&&(r>0||A(r)||y(r))},r.isObject=p,r.isString=E,r.isSymbol=F,r.isTemperature=function(r){return q(r)||K(r)||D(r)},r.isTrue=function(r){return e(r)&&!0===r},r.isUint16Array=k,r.isUint32Array=C,r.isUint8Array=R,r.isUint8ClampedArray=Z,r.isUndefined=function(r){return void 0===r},r.isZero=function(r){return 0===r},r.isZeroNegative=function(r){return 0===r&&1/r===Number.NEGATIVE_INFINITY},r.isZeroPositive=A,Object.defineProperty(r,"__esModule",{value:!0}),r}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itee-validators",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "A library of validation functions use in various Itee projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"itee",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"clean": "gulp clean",
|
|
46
46
|
"lint": "gulp lint",
|
|
47
47
|
"doc": "gulp doc",
|
|
48
|
+
"check-bundling": "gulp check-bundling",
|
|
48
49
|
"build-test": "gulp build-tests",
|
|
49
50
|
"bench": "gulp run-benchmarks",
|
|
50
51
|
"unit": "gulp run-unit-tests",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"del": "^7.0.0",
|
|
71
72
|
"eslint-plugin-mocha": "^10.1.0",
|
|
72
73
|
"fancy-log": "^2.0.0",
|
|
74
|
+
"figlet": "^1.9.3",
|
|
73
75
|
"glob": "^8.0.3",
|
|
74
76
|
"gulp": "^4.0.2",
|
|
75
77
|
"gulp-eslint": "^6.0.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param data {*} The data to check against the array type
|
|
23
23
|
* @returns {boolean} true if data is array, false otherwise
|
|
24
24
|
*/
|
|
25
|
-
export function isArray
|
|
25
|
+
export function isArray( data ) {
|
|
26
26
|
return Array.isArray( data )
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -32,18 +32,18 @@ export function isArray ( data ) {
|
|
|
32
32
|
* @param data {*} The data to check against the array type
|
|
33
33
|
* @returns {boolean} true if data is not array, false otherwise
|
|
34
34
|
*/
|
|
35
|
-
export function isNotArray
|
|
35
|
+
export function isNotArray( data ) {
|
|
36
36
|
return !Array.isArray( data )
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
// #if IS_REMOVE_ON_BUILD
|
|
41
41
|
|
|
42
|
-
export function isArray_0
|
|
42
|
+
export function isArray_0( data ) {
|
|
43
43
|
return data instanceof Array
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function isNotArray_0
|
|
46
|
+
export function isNotArray_0( data ) {
|
|
47
47
|
return !isArray( data )
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -28,7 +28,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
28
28
|
* @param data {*} The data to check against the array of array type
|
|
29
29
|
* @returns {boolean} true if data is an array of array, false otherwise
|
|
30
30
|
*/
|
|
31
|
-
export function isArrayOfArray
|
|
31
|
+
export function isArrayOfArray( data ) {
|
|
32
32
|
|
|
33
33
|
if ( isNotArray( data ) ) { return false }
|
|
34
34
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -49,7 +49,7 @@ export function isArrayOfArray ( data ) {
|
|
|
49
49
|
* @param data {*} The data to check against the array of array type
|
|
50
50
|
* @returns {boolean} true if data is not an array of array, false otherwise
|
|
51
51
|
*/
|
|
52
|
-
export function isNotArrayOfArray
|
|
52
|
+
export function isNotArrayOfArray( data ) {
|
|
53
53
|
|
|
54
54
|
if ( isNotArray( data ) ) { return true }
|
|
55
55
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of booleans
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are boolean, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfBoolean
|
|
29
|
+
export function isArrayOfBoolean( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfBoolean ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of booleans
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are not boolean, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfBoolean
|
|
50
|
+
export function isNotArrayOfBoolean( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of functions
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are functions, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfFunction
|
|
29
|
+
export function isArrayOfFunction( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfFunction ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of functions
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are not functions, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfFunction
|
|
50
|
+
export function isNotArrayOfFunction( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -24,7 +24,7 @@ import { isNotArray } from './isArray'
|
|
|
24
24
|
* @param data {*} The data to check against the single valued array
|
|
25
25
|
* @returns {boolean} true if data is an array with multiples values, false otherwise
|
|
26
26
|
*/
|
|
27
|
-
export function isArrayOfMultiElement
|
|
27
|
+
export function isArrayOfMultiElement( data ) {
|
|
28
28
|
|
|
29
29
|
if ( isNotArray( data ) ) { return false }
|
|
30
30
|
|
|
@@ -25,7 +25,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
25
25
|
* @param data {*} The data to check against the array of null type
|
|
26
26
|
* @returns {boolean} true if data is not an empty array where all values are null, false otherwise
|
|
27
27
|
*/
|
|
28
|
-
export function isArrayOfNull
|
|
28
|
+
export function isArrayOfNull( data ) {
|
|
29
29
|
|
|
30
30
|
if ( isNotArray( data ) ) { return false }
|
|
31
31
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -46,7 +46,7 @@ export function isArrayOfNull ( data ) {
|
|
|
46
46
|
* @param data {*} The data to check against the array of null type
|
|
47
47
|
* @returns {boolean} true if data is not an empty array where all values are not null, false otherwise
|
|
48
48
|
*/
|
|
49
|
-
export function isNotArrayOfNull
|
|
49
|
+
export function isNotArrayOfNull( data ) {
|
|
50
50
|
|
|
51
51
|
if ( isNotArray( data ) ) { return true }
|
|
52
52
|
if ( isEmptyArray( data ) ) { return true }
|
|
@@ -26,7 +26,7 @@ import { isEmptyArray } from './isEmptyArray'
|
|
|
26
26
|
* @param data {*} The data to check against the array of numbers
|
|
27
27
|
* @returns {boolean} true if data is not an empty array where all values are numbers, false otherwise
|
|
28
28
|
*/
|
|
29
|
-
export function isArrayOfNumber
|
|
29
|
+
export function isArrayOfNumber( data ) {
|
|
30
30
|
|
|
31
31
|
if ( isNotArray( data ) ) { return false }
|
|
32
32
|
if ( isEmptyArray( data ) ) { return false }
|
|
@@ -47,7 +47,7 @@ export function isArrayOfNumber ( data ) {
|
|
|
47
47
|
* @param data {*} The data to check against the array of numbers
|
|
48
48
|
* @returns {boolean} true if data is not an empty array where all values are not numbers, false otherwise
|
|
49
49
|
*/
|
|
50
|
-
export function isNotArrayOfNumber
|
|
50
|
+
export function isNotArrayOfNumber( data ) {
|
|
51
51
|
|
|
52
52
|
if ( isNotArray( data ) ) { return true }
|
|
53
53
|
if ( isEmptyArray( data ) ) { return true }
|