chrv-components 1.10.11 → 1.10.13
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.
|
Binary file
|
|
Binary file
|
|
@@ -455,7 +455,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
|
|
|
455
455
|
function maxFileSize(maxSize) {
|
|
456
456
|
return (control) => {
|
|
457
457
|
const value = control.value;
|
|
458
|
-
const
|
|
458
|
+
const sizeInBytes = maxSize * 1024 * 1024;
|
|
459
459
|
let isSizeCompliant = true;
|
|
460
460
|
const errors = {};
|
|
461
461
|
let fileSize = null;
|
|
@@ -463,25 +463,25 @@ function maxFileSize(maxSize) {
|
|
|
463
463
|
return null;
|
|
464
464
|
if (Array.isArray(value)) {
|
|
465
465
|
for (let i = 0; i < value.length; i++) {
|
|
466
|
-
if (value[i].file
|
|
466
|
+
if (!value[i].file)
|
|
467
|
+
continue;
|
|
468
|
+
if (value[i].file.size > sizeInBytes) {
|
|
467
469
|
errors[i] = true;
|
|
468
470
|
isSizeCompliant = false;
|
|
469
471
|
}
|
|
470
472
|
}
|
|
471
473
|
}
|
|
472
474
|
else {
|
|
475
|
+
if (!value.file)
|
|
476
|
+
return null;
|
|
473
477
|
fileSize =
|
|
474
|
-
value instanceof File
|
|
475
|
-
|
|
476
|
-
: value.file
|
|
477
|
-
? value.file?.size
|
|
478
|
-
: null;
|
|
479
|
-
isSizeCompliant = (fileSize && fileSize < sizeInMb) || false;
|
|
478
|
+
(value instanceof File ? value.size : value.file?.size) ?? null;
|
|
479
|
+
isSizeCompliant = fileSize !== null && fileSize < sizeInBytes;
|
|
480
480
|
}
|
|
481
481
|
return !isSizeCompliant
|
|
482
482
|
? {
|
|
483
483
|
maxfilesize: true,
|
|
484
|
-
max:
|
|
484
|
+
max: sizeInBytes,
|
|
485
485
|
actual: fileSize,
|
|
486
486
|
indexes: errors,
|
|
487
487
|
}
|
|
@@ -528,33 +528,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
|
|
|
528
528
|
function minFileSize(minSize) {
|
|
529
529
|
return (control) => {
|
|
530
530
|
const value = control.value;
|
|
531
|
-
const
|
|
531
|
+
const sizeInBytes = minSize * 1024 * 1024;
|
|
532
532
|
let isSizeCompliant = true;
|
|
533
533
|
const errors = {};
|
|
534
534
|
let fileSize = null;
|
|
535
|
+
console.log(value);
|
|
535
536
|
if (value === null)
|
|
536
537
|
return null;
|
|
537
538
|
if (Array.isArray(value)) {
|
|
538
539
|
for (let i = 0; i < value.length; i++) {
|
|
539
|
-
if (value[i].file
|
|
540
|
+
if (!value[i].file)
|
|
541
|
+
continue;
|
|
542
|
+
if (value[i].file.size <= sizeInBytes) {
|
|
540
543
|
errors[i] = true;
|
|
541
544
|
isSizeCompliant = false;
|
|
542
545
|
}
|
|
543
546
|
}
|
|
544
547
|
}
|
|
545
548
|
else {
|
|
549
|
+
if (!value.file)
|
|
550
|
+
return null;
|
|
546
551
|
fileSize =
|
|
547
|
-
value instanceof File
|
|
548
|
-
|
|
549
|
-
: value.file
|
|
550
|
-
? value.file?.size
|
|
551
|
-
: null;
|
|
552
|
-
isSizeCompliant = (fileSize && fileSize >= sizeInMb) || false;
|
|
552
|
+
(value instanceof File ? value.size : value.file?.size) ?? null;
|
|
553
|
+
isSizeCompliant = fileSize !== null && fileSize >= sizeInBytes;
|
|
553
554
|
}
|
|
554
555
|
return !isSizeCompliant
|
|
555
556
|
? {
|
|
556
557
|
minfilesize: true,
|
|
557
|
-
min:
|
|
558
|
+
min: sizeInBytes,
|
|
558
559
|
actual: fileSize,
|
|
559
560
|
indexes: errors,
|
|
560
561
|
}
|