@creative-web-solution/front-library 7.1.49 → 7.1.50

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.
@@ -1,30 +1,37 @@
1
- import { addValidator } from './index';
1
+ import { addValidator } from "./index";
2
2
 
3
3
  /**
4
4
  * File size validation
5
5
  */
6
- addValidator( 'maxfilesize', '[data-max-file-size]', ( $input, value, isLiveValidation ) => {
7
- if (!($input as HTMLInputElement).files?.length) {
6
+ addValidator(
7
+ "maxfilesize",
8
+ "[data-max-file-size]",
9
+ ($input, value, isLiveValidation) => {
10
+ if (!($input as HTMLInputElement).files?.length) {
11
+ return Promise.resolve({
12
+ $input,
13
+ value,
14
+ isValid: true,
15
+ label: "maxfilesize",
16
+ isLiveValidation,
17
+ });
18
+ }
19
+
20
+ const size = ($input as HTMLInputElement).files![0].size;
21
+ const maxSize = Number(
22
+ $input.getAttribute("data-max-file-size") ?? "0",
23
+ );
24
+
8
25
  return Promise.resolve({
9
26
  $input,
10
27
  value,
11
- "isValid": true,
12
- "label": "maxfilesize",
13
- isLiveValidation
28
+ isValid:
29
+ ($input as HTMLInputElement).files?.length === 0 ||
30
+ size <= 0 ||
31
+ maxSize <= 0 ||
32
+ size <= maxSize,
33
+ label: "maxfilesize",
34
+ isLiveValidation,
14
35
  });
15
- }
16
-
17
- const size = ($input as HTMLInputElement).files![0].size;
18
- const maxSize = Number($input.getAttribute('data-max-file-size') ?? "0");
19
- console.log({size, maxSize})
20
- return Promise.resolve({
21
- $input,
22
- value,
23
- "isValid": ($input as HTMLInputElement).files?.length === 0 ||
24
- size <= 0 ||
25
- maxSize <= 0 ||
26
- size <= maxSize,
27
- "label": "maxfilesize",
28
- isLiveValidation
29
- });
30
- } );
36
+ },
37
+ );
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Front Library
2
2
 
3
- @version: 7.1.49
3
+ @version: 7.1.50
4
4
 
5
5
 
6
6
  ## Use
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@creative-web-solution/front-library",
3
3
  "title": "Frontend library",
4
4
  "description": "Frontend functions and modules",
5
- "version": "7.1.49",
5
+ "version": "7.1.50",
6
6
  "homepage": "https://github.com/creative-web-solution/front-library",
7
7
  "author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
8
8
  "keywords": [],