@excofy/utils 1.0.15 → 2.0.0

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
@@ -446,6 +446,15 @@ function createValidator() {
446
446
  }
447
447
  return validator;
448
448
  },
449
+ sanitizeAlphanumeric() {
450
+ if (shouldSkipValidation()) return validator;
451
+ if (typeof current.value === "string") {
452
+ const cleaned = current.value.replace(/[^A-Za-z0-9]/g, "").trim();
453
+ current.value = cleaned;
454
+ current.inputs[current.field] = cleaned;
455
+ }
456
+ return validator;
457
+ },
449
458
  sanitizeDigits() {
450
459
  if (shouldSkipValidation()) return validator;
451
460
  if (typeof current.value === "string") {
package/dist/index.d.cts CHANGED
@@ -32,6 +32,7 @@ interface ValidatorField {
32
32
  slug(message: string): ValidatorField;
33
33
  sanitize(): ValidatorField;
34
34
  sanitizeAlphaSpaces(): ValidatorField;
35
+ sanitizeAlphanumeric(): ValidatorField;
35
36
  sanitizeDigits(): ValidatorField;
36
37
  sanitizePreservingNewlines(): ValidatorField;
37
38
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ interface ValidatorField {
32
32
  slug(message: string): ValidatorField;
33
33
  sanitize(): ValidatorField;
34
34
  sanitizeAlphaSpaces(): ValidatorField;
35
+ sanitizeAlphanumeric(): ValidatorField;
35
36
  sanitizeDigits(): ValidatorField;
36
37
  sanitizePreservingNewlines(): ValidatorField;
37
38
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
package/dist/index.js CHANGED
@@ -410,6 +410,15 @@ function createValidator() {
410
410
  }
411
411
  return validator;
412
412
  },
413
+ sanitizeAlphanumeric() {
414
+ if (shouldSkipValidation()) return validator;
415
+ if (typeof current.value === "string") {
416
+ const cleaned = current.value.replace(/[^A-Za-z0-9]/g, "").trim();
417
+ current.value = cleaned;
418
+ current.inputs[current.field] = cleaned;
419
+ }
420
+ return validator;
421
+ },
413
422
  sanitizeDigits() {
414
423
  if (shouldSkipValidation()) return validator;
415
424
  if (typeof current.value === "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excofy/utils",
3
- "version": "1.0.15",
3
+ "version": "2.0.0",
4
4
  "description": "Biblioteca de utilitários para o Excofy",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -39,6 +39,7 @@ interface ValidatorField {
39
39
  slug(message: string): ValidatorField;
40
40
  sanitize(): ValidatorField;
41
41
  sanitizeAlphaSpaces(): ValidatorField;
42
+ sanitizeAlphanumeric(): ValidatorField;
42
43
  sanitizeDigits(): ValidatorField;
43
44
  sanitizePreservingNewlines(): ValidatorField;
44
45
  sanitizeHTML(tags?: AllowedTag[]): ValidatorField;
@@ -421,6 +422,20 @@ export function createValidator<
421
422
  return validator;
422
423
  },
423
424
 
425
+ sanitizeAlphanumeric() {
426
+ if (shouldSkipValidation()) return validator;
427
+
428
+ if (typeof current.value === 'string') {
429
+ const cleaned = current.value
430
+ .replace(/[^A-Za-z0-9]/g, '') // remove tudo que não é letra ou número
431
+ .trim();
432
+ current.value = cleaned;
433
+ current.inputs[current.field] = cleaned as TRaw[keyof TRaw];
434
+ }
435
+
436
+ return validator;
437
+ },
438
+
424
439
  sanitizeDigits() {
425
440
  if (shouldSkipValidation()) return validator;
426
441