Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(validations): use validations yaml from new repo #321

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
81 changes: 64 additions & 17 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
"react-router-dom": "6.11.1",
"react-scroll": "^1.8.9",
"react-select": "^5.7.4",
"regtech-regex": "https://github.com/cfpb/regtech-regex#1-create-shared-data-validations-yaml-and-repo-setup",
"vite-plugin-svgr": "^3.2.0",
"zod": "^3.22.0",
"zustand": "^4.4.1"
},
"devDependencies": {
"@modyfi/vite-plugin-yaml": "^1.1.0",
"@nabla/vite-plugin-eslint": "1.5.0",
"@tailwindcss/forms": "0.5.3",
"@testing-library/cypress": "^10.0.1",
Expand Down
26 changes: 14 additions & 12 deletions src/types/formTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Five, One } from 'utils/constants';
import { z } from 'zod';

import YamlDataValidations from 'regtech-regex/src/validations.yaml';

export enum FormFieldsHeaderError {
firstName = 'Enter your first name',
lastName = 'Enter your last name',
Expand Down Expand Up @@ -29,13 +31,10 @@ export const domainSchema = z.object({

// Used in most forms
export const institutionDetailsApiTypeSchema = z.object({
lei: z
.string()
.trim()
.regex(/([\dA-Za-z]{20})/, {
message:
'Must be 20 characters and only contain a-z, A-Z, and 0-9 (no special characters)',
}),
lei: z.string().trim().regex(new RegExp(YamlDataValidations.lei.regex), {
message:
'Must be 20 characters and only contain a-z, A-Z, and 0-9 (no special characters)',
}),
is_active: z.boolean(),
name: z.string().trim().min(One, {
message: "You must enter the financial institution's name.",
Expand All @@ -46,7 +45,7 @@ export const institutionDetailsApiTypeSchema = z.object({
.regex(/^(\d{2}-\d{7})/, {
message: 'Must be 2 digits, followed by a dash, followed by 7 digits.',
}),
rssd_id: z.number(),
rssd_id: z.string().regex(new RegExp(YamlDataValidations.rssd_id.regex)),
primary_federal_regulator: z.object({
id: z.string(),
name: z.string(),
Expand Down Expand Up @@ -132,7 +131,7 @@ export const basicInfoSchema = z.object({
.string()
.trim()
.min(Five as number, { message: 'You must have a valid email address' })
.email({
.regex(new RegExp(YamlDataValidations.email.regex), {
message: 'You must have a valid email address and in the correct format.',
}),
});
Expand Down Expand Up @@ -210,9 +209,12 @@ const noZeroesZipCodeRegex = /^(?!0{5})\d{5}(?:[\s-](?!0{4})\d{4})?$/;

// Point of Contact
export const pointOfContactSchema = basicInfoSchema.extend({
phone: z.string().trim().regex(usPhoneNumberRegex, {
message: "Must in '999-999-9999' format",
}),
phone: z
.string()
.trim()
.regex(new RegExp(YamlDataValidations.simple_us_phone_number.regex), {
message: "Must in '999-999-9999' format",
}),
hq_address_street_1: z.string().trim().min(One, {
message: 'You must enter your street address',
}),
Expand Down
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { defineConfig, loadEnv } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import tsconfigPaths from 'vite-tsconfig-paths';

import ViteYaml from '@modyfi/vite-plugin-yaml';
import svgr from 'vite-plugin-svgr';

export default async ({ mode }) => {
Expand Down Expand Up @@ -81,6 +82,7 @@ export default async ({ mode }) => {
svgr(),
tsconfigPaths(),
react(),
ViteYaml(),
...(mode === 'test'
? []
: [
Expand Down
59 changes: 44 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,19 @@ __metadata:
languageName: node
linkType: hard

"@modyfi/vite-plugin-yaml@npm:^1.1.0":
version: 1.1.0
resolution: "@modyfi/vite-plugin-yaml@npm:1.1.0"
dependencies:
"@rollup/pluginutils": 5.1.0
js-yaml: 4.1.0
tosource: 2.0.0-alpha.3
peerDependencies:
vite: ^3.2.7 || ^4.0.5 || ^5.0.5
checksum: 6989cde89323321b714b69d11b9125c8d3483a8c6ace536df313edd653180e85e6013effbc6cb8b89e6f9d6e107a10f7a82fadf6a44e81255b437702d5dd1db0
languageName: node
linkType: hard

"@mswjs/cookies@npm:^0.2.2":
version: 0.2.2
resolution: "@mswjs/cookies@npm:0.2.2"
Expand Down Expand Up @@ -2329,20 +2342,7 @@ __metadata:
languageName: node
linkType: hard

"@rollup/pluginutils@npm:^3.1.0":
version: 3.1.0
resolution: "@rollup/pluginutils@npm:3.1.0"
dependencies:
"@types/estree": 0.0.39
estree-walker: ^1.0.1
picomatch: ^2.2.2
peerDependencies:
rollup: ^1.20.0||^2.0.0
checksum: 8be16e27863c219edbb25a4e6ec2fe0e1e451d9e917b6a43cf2ae5bc025a6b8faaa40f82a6e53b66d0de37b58ff472c6c3d57a83037ae635041f8df959d6d9aa
languageName: node
linkType: hard

"@rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.0.4":
"@rollup/pluginutils@npm:5.1.0, @rollup/pluginutils@npm:^5.0.1, @rollup/pluginutils@npm:^5.0.4":
version: 5.1.0
resolution: "@rollup/pluginutils@npm:5.1.0"
dependencies:
Expand All @@ -2358,6 +2358,19 @@ __metadata:
languageName: node
linkType: hard

"@rollup/pluginutils@npm:^3.1.0":
version: 3.1.0
resolution: "@rollup/pluginutils@npm:3.1.0"
dependencies:
"@types/estree": 0.0.39
estree-walker: ^1.0.1
picomatch: ^2.2.2
peerDependencies:
rollup: ^1.20.0||^2.0.0
checksum: 8be16e27863c219edbb25a4e6ec2fe0e1e451d9e917b6a43cf2ae5bc025a6b8faaa40f82a6e53b66d0de37b58ff472c6c3d57a83037ae635041f8df959d6d9aa
languageName: node
linkType: hard

"@sideway/address@npm:^4.1.3":
version: 4.1.4
resolution: "@sideway/address@npm:4.1.4"
Expand Down Expand Up @@ -4115,6 +4128,7 @@ __metadata:
resolution: "cfpb-small-business-lending@workspace:."
dependencies:
"@hookform/resolvers": ^3.2.0
"@modyfi/vite-plugin-yaml": ^1.1.0
"@nabla/vite-plugin-eslint": 1.5.0
"@tailwindcss/forms": 0.5.3
"@tanstack/react-query": 4.29.7
Expand Down Expand Up @@ -4181,6 +4195,7 @@ __metadata:
react-router-dom: 6.11.1
react-scroll: ^1.8.9
react-select: ^5.7.4
regtech-regex: "https://github.com/cfpb/regtech-regex#1-create-shared-data-validations-yaml-and-repo-setup"
start-server-and-test: 2.0.0
stylelint: 15.6.1
stylelint-config-prettier: 9.0.5
Expand Down Expand Up @@ -7751,7 +7766,7 @@ display-element-css@cfpb/storybook-addon-display-element-css:
languageName: node
linkType: hard

"js-yaml@npm:^4.1.0":
"js-yaml@npm:4.1.0, js-yaml@npm:^4.1.0":
version: 4.1.0
resolution: "js-yaml@npm:4.1.0"
dependencies:
Expand Down Expand Up @@ -10208,6 +10223,13 @@ display-element-css@cfpb/storybook-addon-display-element-css:
languageName: node
linkType: hard

"regtech-regex@https://github.com/cfpb/regtech-regex#1-create-shared-data-validations-yaml-and-repo-setup":
version: 1.0.0
resolution: "regtech-regex@https://github.com/cfpb/regtech-regex.git#commit=55e8ca147cb73bcebb40c4aa02013c08b7e9ad28"
checksum: acaf05e6881323aa70cde86a85438103e49b1930f5208a32b03b48fc76c540049a6e5bcd5aae1c954db8f7e240289eb8bfaa886f170f3a62569ff248f048fd74
languageName: node
linkType: hard

"request-progress@npm:^3.0.0":
version: 3.0.0
resolution: "request-progress@npm:3.0.0"
Expand Down Expand Up @@ -11507,6 +11529,13 @@ display-element-css@cfpb/storybook-addon-display-element-css:
languageName: node
linkType: hard

"tosource@npm:2.0.0-alpha.3":
version: 2.0.0-alpha.3
resolution: "tosource@npm:2.0.0-alpha.3"
checksum: bc03a7571de8ed4306e6721283fa891f2adcab9dd80c46f6f177d4259b34bb192fe3a2cb3e1e2ce16f9db0bc7e534acfcb5478ab094b0ba255f98abfce6dab46
languageName: node
linkType: hard

"tough-cookie@npm:^4.1.2, tough-cookie@npm:^4.1.3":
version: 4.1.3
resolution: "tough-cookie@npm:4.1.3"
Expand Down