vanilla-jui 1.7.23 → 1.7.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jui",
3
- "version": "1.7.23",
3
+ "version": "1.7.24",
4
4
  "private": false,
5
5
  "description": "A lightweight, reactive, and fully customizable vanilla JS UI library.",
6
6
  "keywords": [
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from './utilities/http.ts';
11
11
  // export * from './utilities/locale.ts';
12
12
  export * from './utilities/object.ts';
13
13
  export * from './utilities/timer.ts';
14
+ export * from './utilities/string.ts';
14
15
  export * from './utilities/types.ts';
15
16
  export * from './utilities/merge.ts';
16
17
  export * from './utilities/config.ts';
@@ -0,0 +1,3 @@
1
+ export function removeSpaces(value: string | null | undefined): string {
2
+ return value?.replace(/\s+/g, '') ?? '';
3
+ }
@@ -8,6 +8,7 @@ import {
8
8
  } from '../utilities/dom.ts';
9
9
  import { createEventManager } from '../utilities/events.ts';
10
10
  import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
11
+ import { removeSpaces } from '../utilities/string.ts';
11
12
  import { validateParam } from '../utilities/types.ts';
12
13
 
13
14
  type ValidatorElement =
@@ -181,7 +182,7 @@ function validateMinLength(
181
182
  minLength: unknown
182
183
  ): boolean {
183
184
  if (typeof minLength !== 'number') return true;
184
- return element.value.length >= minLength;
185
+ return removeSpaces(element.value).length >= minLength;
185
186
  }
186
187
 
187
188
  function validateMaxLength(
@@ -189,12 +190,12 @@ function validateMaxLength(
189
190
  maxLength: unknown
190
191
  ): boolean {
191
192
  if (typeof maxLength !== 'number') return true;
192
- return element.value.length <= maxLength;
193
+ return removeSpaces(element.value).length <= maxLength;
193
194
  }
194
195
 
195
196
  function validateEmail(element: ValidatorElement): boolean {
196
197
  const emailPattern = /^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/;
197
- return emailPattern.test(element.value);
198
+ return emailPattern.test(removeSpaces(element.value));
198
199
  }
199
200
 
200
201
  function validateEqualTo(