@excofy/utils 1.0.10 → 1.0.11
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.cjs +9 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +9 -0
- package/package.json +1 -1
- package/src/helpers/validator.ts +13 -0
package/dist/index.cjs
CHANGED
|
@@ -435,6 +435,15 @@ function createValidator() {
|
|
|
435
435
|
}
|
|
436
436
|
return validator;
|
|
437
437
|
},
|
|
438
|
+
sanitizeDigits() {
|
|
439
|
+
if (shouldSkipValidation()) return validator;
|
|
440
|
+
if (typeof current.value === "string") {
|
|
441
|
+
const digitsOnly = current.value.replace(/\D+/g, "");
|
|
442
|
+
current.value = digitsOnly;
|
|
443
|
+
current.inputs[current.field] = digitsOnly;
|
|
444
|
+
}
|
|
445
|
+
return validator;
|
|
446
|
+
},
|
|
438
447
|
sanitizePreservingNewlines() {
|
|
439
448
|
if (shouldSkipValidation()) {
|
|
440
449
|
return validator;
|
package/dist/index.d.cts
CHANGED
|
@@ -31,6 +31,7 @@ interface ValidatorField {
|
|
|
31
31
|
transform<U>(fn: (value: TInputValue) => U): ValidatorField;
|
|
32
32
|
slug(message: string): ValidatorField;
|
|
33
33
|
sanitize(): ValidatorField;
|
|
34
|
+
sanitizeDigits(): ValidatorField;
|
|
34
35
|
sanitizePreservingNewlines(): ValidatorField;
|
|
35
36
|
sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
|
|
36
37
|
url(message: string): ValidatorField;
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ interface ValidatorField {
|
|
|
31
31
|
transform<U>(fn: (value: TInputValue) => U): ValidatorField;
|
|
32
32
|
slug(message: string): ValidatorField;
|
|
33
33
|
sanitize(): ValidatorField;
|
|
34
|
+
sanitizeDigits(): ValidatorField;
|
|
34
35
|
sanitizePreservingNewlines(): ValidatorField;
|
|
35
36
|
sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
|
|
36
37
|
url(message: string): ValidatorField;
|
package/dist/index.js
CHANGED
|
@@ -401,6 +401,15 @@ function createValidator() {
|
|
|
401
401
|
}
|
|
402
402
|
return validator;
|
|
403
403
|
},
|
|
404
|
+
sanitizeDigits() {
|
|
405
|
+
if (shouldSkipValidation()) return validator;
|
|
406
|
+
if (typeof current.value === "string") {
|
|
407
|
+
const digitsOnly = current.value.replace(/\D+/g, "");
|
|
408
|
+
current.value = digitsOnly;
|
|
409
|
+
current.inputs[current.field] = digitsOnly;
|
|
410
|
+
}
|
|
411
|
+
return validator;
|
|
412
|
+
},
|
|
404
413
|
sanitizePreservingNewlines() {
|
|
405
414
|
if (shouldSkipValidation()) {
|
|
406
415
|
return validator;
|
package/package.json
CHANGED
package/src/helpers/validator.ts
CHANGED
|
@@ -38,6 +38,7 @@ interface ValidatorField {
|
|
|
38
38
|
transform<U>(fn: (value: TInputValue) => U): ValidatorField;
|
|
39
39
|
slug(message: string): ValidatorField;
|
|
40
40
|
sanitize(): ValidatorField;
|
|
41
|
+
sanitizeDigits(): ValidatorField;
|
|
41
42
|
sanitizePreservingNewlines(): ValidatorField;
|
|
42
43
|
sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
|
|
43
44
|
url(message: string): ValidatorField;
|
|
@@ -407,6 +408,18 @@ export function createValidator<
|
|
|
407
408
|
return validator;
|
|
408
409
|
},
|
|
409
410
|
|
|
411
|
+
sanitizeDigits() {
|
|
412
|
+
if (shouldSkipValidation()) return validator;
|
|
413
|
+
|
|
414
|
+
if (typeof current.value === 'string') {
|
|
415
|
+
const digitsOnly = current.value.replace(/\D+/g, '');
|
|
416
|
+
current.value = digitsOnly;
|
|
417
|
+
current.inputs[current.field] = digitsOnly as TRaw[keyof TRaw];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return validator;
|
|
421
|
+
},
|
|
422
|
+
|
|
410
423
|
sanitizePreservingNewlines() {
|
|
411
424
|
if (shouldSkipValidation()) {
|
|
412
425
|
return validator;
|