@excofy/utils 1.0.10 → 1.0.12

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 CHANGED
@@ -435,6 +435,24 @@ function createValidator() {
435
435
  }
436
436
  return validator;
437
437
  },
438
+ sanitizeAlphaSpaces() {
439
+ if (shouldSkipValidation()) return validator;
440
+ if (typeof current.value === "string") {
441
+ const cleaned = current.value.replace(/[^A-Za-zÀ-ÿ\s]/g, "");
442
+ current.value = cleaned;
443
+ current.inputs[current.field] = cleaned;
444
+ }
445
+ return validator;
446
+ },
447
+ sanitizeDigits() {
448
+ if (shouldSkipValidation()) return validator;
449
+ if (typeof current.value === "string") {
450
+ const digitsOnly = current.value.replace(/\D+/g, "");
451
+ current.value = digitsOnly;
452
+ current.inputs[current.field] = digitsOnly;
453
+ }
454
+ return validator;
455
+ },
438
456
  sanitizePreservingNewlines() {
439
457
  if (shouldSkipValidation()) {
440
458
  return validator;
package/dist/index.d.cts CHANGED
@@ -31,6 +31,8 @@ interface ValidatorField {
31
31
  transform<U>(fn: (value: TInputValue) => U): ValidatorField;
32
32
  slug(message: string): ValidatorField;
33
33
  sanitize(): ValidatorField;
34
+ sanitizeAlphaSpaces(): ValidatorField;
35
+ sanitizeDigits(): ValidatorField;
34
36
  sanitizePreservingNewlines(): ValidatorField;
35
37
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
36
38
  url(message: string): ValidatorField;
package/dist/index.d.ts CHANGED
@@ -31,6 +31,8 @@ interface ValidatorField {
31
31
  transform<U>(fn: (value: TInputValue) => U): ValidatorField;
32
32
  slug(message: string): ValidatorField;
33
33
  sanitize(): ValidatorField;
34
+ sanitizeAlphaSpaces(): ValidatorField;
35
+ sanitizeDigits(): ValidatorField;
34
36
  sanitizePreservingNewlines(): ValidatorField;
35
37
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
36
38
  url(message: string): ValidatorField;
package/dist/index.js CHANGED
@@ -401,6 +401,24 @@ function createValidator() {
401
401
  }
402
402
  return validator;
403
403
  },
404
+ sanitizeAlphaSpaces() {
405
+ if (shouldSkipValidation()) return validator;
406
+ if (typeof current.value === "string") {
407
+ const cleaned = current.value.replace(/[^A-Za-zÀ-ÿ\s]/g, "");
408
+ current.value = cleaned;
409
+ current.inputs[current.field] = cleaned;
410
+ }
411
+ return validator;
412
+ },
413
+ sanitizeDigits() {
414
+ if (shouldSkipValidation()) return validator;
415
+ if (typeof current.value === "string") {
416
+ const digitsOnly = current.value.replace(/\D+/g, "");
417
+ current.value = digitsOnly;
418
+ current.inputs[current.field] = digitsOnly;
419
+ }
420
+ return validator;
421
+ },
404
422
  sanitizePreservingNewlines() {
405
423
  if (shouldSkipValidation()) {
406
424
  return validator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excofy/utils",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Biblioteca de utilitários para o Excofy",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -38,6 +38,8 @@ interface ValidatorField {
38
38
  transform<U>(fn: (value: TInputValue) => U): ValidatorField;
39
39
  slug(message: string): ValidatorField;
40
40
  sanitize(): ValidatorField;
41
+ sanitizeAlphaSpaces(): ValidatorField;
42
+ sanitizeDigits(): ValidatorField;
41
43
  sanitizePreservingNewlines(): ValidatorField;
42
44
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
43
45
  url(message: string): ValidatorField;
@@ -407,6 +409,30 @@ export function createValidator<
407
409
  return validator;
408
410
  },
409
411
 
412
+ sanitizeAlphaSpaces() {
413
+ if (shouldSkipValidation()) return validator;
414
+
415
+ if (typeof current.value === 'string') {
416
+ const cleaned = current.value.replace(/[^A-Za-zÀ-ÿ\s]/g, '');
417
+ current.value = cleaned;
418
+ current.inputs[current.field] = cleaned as TRaw[keyof TRaw];
419
+ }
420
+
421
+ return validator;
422
+ },
423
+
424
+ sanitizeDigits() {
425
+ if (shouldSkipValidation()) return validator;
426
+
427
+ if (typeof current.value === 'string') {
428
+ const digitsOnly = current.value.replace(/\D+/g, '');
429
+ current.value = digitsOnly;
430
+ current.inputs[current.field] = digitsOnly as TRaw[keyof TRaw];
431
+ }
432
+
433
+ return validator;
434
+ },
435
+
410
436
  sanitizePreservingNewlines() {
411
437
  if (shouldSkipValidation()) {
412
438
  return validator;