tide-design-system 2.5.2 → 2.5.4

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.
@@ -15,7 +15,7 @@ export const FORMAT_REGEX = {
15
15
  alphaNumberOrEmpty: /^$|^[a-z0-9]+$/i,
16
16
  alphaSpace: /^[a-zA-Z ]+$/g,
17
17
  email:
18
- /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
18
+ /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(?!(?:[a-zA-Z0-9-]+\.)*(?<tld>[a-zA-Z]{2,})\.\k<tld>$)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}))$/,
19
19
  numberFormatted: /^$|(?=.)^\$?(([1-9][0-9]{0,2}(,[0-9]{3})*)|0)?(\.[0-9]{1,2})?$/,
20
20
  phone: /^(?:\d{3}-\d{3}-\d{4}|\d{1}-\d{3}-\d{3}-\d{4})?$/,
21
21
  price: /(?=.)^\$?(([1-9][0-9]{0,2}(,[0-9]{3})*)|0)?(\.[0-9]{1,2})?$/,
@@ -62,7 +62,7 @@ export const getFieldValidationResult = ({
62
62
 
63
63
  // custom validator prop errors from have second highest precedence
64
64
  if (validators) {
65
- const validation = validateProperty(value.value, validators);
65
+ const validation = validateProperty(value.value ?? '', validators);
66
66
 
67
67
  if (!validation.valid) {
68
68
  return validation;
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
+ import { FORMAT_REGEX } from '../src/types/Formatted';
3
4
  import {
4
5
  formatCamelCase,
5
6
  formatKebabCase,
@@ -428,3 +429,42 @@ describe('@/src/utilities/format.ts', () => {
428
429
  });
429
430
  });
430
431
  });
432
+
433
+ describe('@/src/types/Formatted.ts', () => {
434
+ describe('FORMAT_REGEX.email', () => {
435
+ it('accepts a standard email address.', () => {
436
+ const input = 'john.doe@gmail.com';
437
+ const output = true;
438
+
439
+ expect(FORMAT_REGEX.email.test(input)).toEqual(output);
440
+ });
441
+
442
+ it('accepts an email address with subdomains.', () => {
443
+ const input = 'john.doe@mail.sub.example.co.uk';
444
+ const output = true;
445
+
446
+ expect(FORMAT_REGEX.email.test(input)).toEqual(output);
447
+ });
448
+
449
+ it('rejects an email address that ends with a repeated TLD label (e.g. .com.com).', () => {
450
+ const input = 'john@gmail.com.com';
451
+ const output = false;
452
+
453
+ expect(FORMAT_REGEX.email.test(input)).toEqual(output);
454
+ });
455
+
456
+ it('rejects an email address that ends with a repeated TLD label (e.g. .net.net).', () => {
457
+ const input = 'john@company.net.net';
458
+ const output = false;
459
+
460
+ expect(FORMAT_REGEX.email.test(input)).toEqual(output);
461
+ });
462
+
463
+ it('rejects an email address missing a valid top-level domain.', () => {
464
+ const input = 'john@gmail';
465
+ const output = false;
466
+
467
+ expect(FORMAT_REGEX.email.test(input)).toEqual(output);
468
+ });
469
+ });
470
+ });