@alviere/core 0.16.3 → 0.17.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.mjs CHANGED
@@ -420,7 +420,7 @@ class Validator {
420
420
  * @param date - The date string to validate
421
421
  * @param format - The expected date format (default: 'YYYY-MM-DD')
422
422
  */
423
- date(date, format = "YYYY-MM-DD") {
423
+ date(date, _format = "YYYY-MM-DD") {
424
424
  if (!date || typeof date !== "string") {
425
425
  return "Please enter a valid date.";
426
426
  }
@@ -526,6 +526,26 @@ class Validator {
526
526
  }
527
527
  return null;
528
528
  }
529
+ /**
530
+ * Validates that a value is a valid human name.
531
+ * Accepts Unicode letters (including diacritics), combining marks, spaces,
532
+ * digits, hyphens, apostrophes, periods, and commas. Diacritics, periods,
533
+ * and commas are accepted here so the user is never shown a validation error
534
+ * for a legitimate name — callers are responsible for normalising the value
535
+ * to the API-accepted character set before sending (API regex:
536
+ * ^[a-zA-Z0-9' -]{1,40}$).
537
+ * @param value - The value to validate
538
+ * @param fieldName - Optional field name for error message
539
+ */
540
+ nameField(value, fieldName) {
541
+ if (!value || typeof value !== "string") {
542
+ return fieldName ? `${fieldName} is required.` : "This field is required.";
543
+ }
544
+ if (!/^[-.,\p{L}\p{M}\s\d\u0027\u2019]+$/u.test(value.trim())) {
545
+ return fieldName ? `${fieldName} must contain only letters, numbers, spaces, hyphens, apostrophes, periods, and commas.` : "Must contain only letters, numbers, spaces, hyphens, apostrophes, periods, and commas.";
546
+ }
547
+ return null;
548
+ }
529
549
  /**
530
550
  * Validates that a value contains only letters and numbers
531
551
  * @param value - The value to validate