@verifiedinc-public/shared-ui-elements 0.14.5-beta.3 → 0.14.5-beta.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.
@@ -3,3 +3,4 @@ export * from './date';
3
3
  export * from './phone';
4
4
  export * from './masks/index';
5
5
  export * from './omitProperty';
6
+ export * from './ssn';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Formats a SSN to the following format: •••-••-3333
3
+ * accepts SSNs with or without dashes (e.g. '111-22-3333' or '11223333')
4
+ * @param {string} rawValue the raw value of the ssncredential
5
+ * @returns {string} the formatted value
6
+ */
7
+ export declare const ssnFormatter: (rawValue: string) => string;
@@ -1,2 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  export declare const SSNSchema: z.ZodString;
3
+ /**
4
+ * It accepts SSN in the format '•••-••-1900' or '123-45-6789'.
5
+ * When dealing with masked SSN, in the backend you will need to call 1-Click API GET to get the unmasked version of SSN again.
6
+ * If this is the user input SSN there will be no need to call the 1-Click API GET.
7
+ */
8
+ export declare const MaskedAndUnmaskedSSNSchema: z.ZodEffects<z.ZodString, string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "0.14.5-beta.3",
3
+ "version": "0.14.5-beta.4",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],
@@ -3,3 +3,4 @@ export * from './date';
3
3
  export * from './phone';
4
4
  export * from './masks/index';
5
5
  export * from './omitProperty';
6
+ export * from './ssn';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a SSN to the following format: •••-••-3333
3
+ * accepts SSNs with or without dashes (e.g. '111-22-3333' or '11223333')
4
+ * @param {string} rawValue the raw value of the ssncredential
5
+ * @returns {string} the formatted value
6
+ */
7
+ export const ssnFormatter = (rawValue: string) =>
8
+ rawValue.replace(/(\d{3})-?(\d{2})-?(\d{4})/, '•••-••-$3');
@@ -4,3 +4,21 @@ import { z } from 'zod';
4
4
  export const SSNSchema = z
5
5
  .string()
6
6
  .regex(/^(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$/);
7
+
8
+ /**
9
+ * It accepts SSN in the format '•••-••-1900' or '123-45-6789'.
10
+ * When dealing with masked SSN, in the backend you will need to call 1-Click API GET to get the unmasked version of SSN again.
11
+ * If this is the user input SSN there will be no need to call the 1-Click API GET.
12
+ */
13
+ // SSN schema, unmasked validation regex were gathered from: https://uibakery.io/regex-library/ssn
14
+ export const MaskedAndUnmaskedSSNSchema = z.string().refine(
15
+ (val) => {
16
+ const maskedRegex = /^•••-••-(\d{4})$/;
17
+ const unmaskedRegex = /^(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$/;
18
+
19
+ return maskedRegex.test(val) || unmaskedRegex.test(val);
20
+ },
21
+ {
22
+ message: 'Invalid SSN',
23
+ },
24
+ );