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/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/utilities/string.ts +3 -0
- package/src/utilities/validator.ts +4 -3
package/package.json
CHANGED
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';
|
|
@@ -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(
|