From 01c083e408caa9a3b9c9676ceed21bb2be773872 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Thu, 21 Mar 2024 20:31:01 -0700 Subject: [PATCH 1/8] feat(validations): add validations yaml and set up repo docs --- .github/ISSUE_TEMPLATE.md | 12 ---- .github/PULL_REQUEST_TEMPLATE.md | 43 +------------ CHANGELOG.md | 13 +--- CONTRIBUTING.md | 18 +----- INSTALL.md | 3 - README.md | 100 +++++++++---------------------- opensource-checklist.md | 73 ---------------------- regtech-regex.svg | 10 ++++ validations.yaml | 36 +++++++++++ 9 files changed, 78 insertions(+), 230 deletions(-) delete mode 100644 INSTALL.md delete mode 100644 opensource-checklist.md create mode 100644 regtech-regex.svg create mode 100644 validations.yaml diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 63a2ff5..714bb93 100755 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,16 +2,4 @@ Short description explaining the high-level reason for the new issue. ## Current behavior - ## Expected behavior - - -## Steps to replicate behavior (include URLs) - -1. - - -## Screenshots - - - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 875ae6f..5536e76 100755 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,24 +1,9 @@ [Short description explaining the high-level reason for the pull request] -## Additions - -- - -## Removals - -- - ## Changes - -## Testing - -1. - -## Screenshots - - ## Notes - @@ -32,36 +17,10 @@ - [ ] PR has an informative and human-readable title - [ ] Changes are limited to a single goal (no scope creep) - [ ] Code can be automatically merged (no conflicts) -- [ ] Code follows the standards laid out in the [development playbook](https://github.com/cfpb/development) - [ ] Passes all existing automated tests -- [ ] Any _change_ in functionality is tested -- [ ] New functions are documented (with a description, list of inputs, and expected output) -- [ ] Placeholder code is flagged / future todos are captured in comments -- [ ] Visually tested in supported browsers and devices (see checklist below :point_down:) - [ ] Project documentation has been updated (including the "Unreleased" section of the CHANGELOG) -- [ ] Reviewers requested with the [Reviewers tool](https://help.github.com/articles/requesting-a-pull-request-review/) :arrow_right: +- [ ] Reviewers requested ## Testing checklist -### Browsers - -- [ ] Chrome -- [ ] Firefox -- [ ] Safari -- [ ] Internet Explorer 8, 9, 10, and 11 -- [ ] Edge -- [ ] iOS Safari -- [ ] Chrome for Android - -### Accessibility - -- [ ] Keyboard friendly -- [ ] Screen reader friendly - -### Other - -- [ ] Is useable without CSS -- [ ] Is useable without JS -- [ ] Flexible from small to large screens - [ ] No linting errors or warnings -- [ ] JavaScript tests are passing diff --git a/CHANGELOG.md b/CHANGELOG.md index da5a178..b1bf0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,8 @@ All notable changes to this project will be documented in this file. We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. - -## x.y.z - YYYY-MM-DD +## 1.0.0 - 2024-03-21 ### Added -- Lorem ipsum dolor sit amet - -### Deprecated -- Nothing. - -### Removed -- Nothing. -### Fixed -- Nothing. +- Initial release of validations.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ec64336..7f123e8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,11 +5,10 @@ > feature request, you are agreeing to comply with this waiver of copyright interest. > Details can be found in our [TERMS](TERMS.md) and [LICENSE](LICENSE). - There are two primary ways to help: - - Using the issue tracker, and - - Changing the code-base. +- Using the issue tracker, and +- Changing the code-base. ## Using the issue tracker @@ -21,7 +20,6 @@ Use the issue tracker to find ways to contribute. Find a bug or a feature, menti the issue that you will take on that effort, then follow the _Changing the code-base_ guidance below. - ## Changing the code-base Generally speaking, you should fork this repository, make changes in your @@ -30,15 +28,3 @@ unit tests that validate implemented features and the presence or lack of defect Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing code-base. - - -## Browser support - -We configure our build chain tools -(typically [Autoprefixer](https://github.com/postcss/autoprefixer) -and [Babel](https://babeljs.io)) -to support a reasonable set of backward compatibility with older browsers. - -Please read up on -[our current browser support guidance](https://github.com/cfpb/development/blob/main/guides/browser-support.md) -and follow it when contributing to this project. diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 4c199e6..0000000 --- a/INSTALL.md +++ /dev/null @@ -1,3 +0,0 @@ -# Installation instructions - -Detailed instructions on how to install, configure, and get the project running. diff --git a/README.md b/README.md index 8f69e34..aba385e 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,60 @@ -#### CFPB Open Source Project Template Instructions +# regtech-regex -1. Create a new project. -2. [Copy these files into the new project](#installation) -3. Update the README, replacing the contents below as prescribed. -4. Add any libraries, assets, or hard dependencies whose source code will be included - in the project's repository to the _Exceptions_ section in the [TERMS](TERMS.md). - - If no exceptions are needed, remove that section from TERMS. -5. If working with an existing code base, answer the questions on the [open source checklist](opensource-checklist.md) -6. Delete these instructions and everything up to the _Project Title_ from the README. -7. Write some great software and tell people about it. +Shared data validations using regular expressions for use at the CFPB. This repo aims to collect sensible regex data validations in one YAML file for use across multiple tech stacks in the Small Business Lending project and maybe beyond. -> Keep the README fresh! It's the first thing people see and will make the initial impression. - -## Installation - -To install all of the template files, run the following script from the root of your project's directory: - -``` -bash -c "$(curl -s https://raw.githubusercontent.com/CFPB/development/main/open-source-template.sh)" -``` - ----- - -# Project Title - -**Description**: Put a meaningful, short, plain-language description of what -this project is trying to accomplish and why it matters. -Describe the problem(s) this project solves. -Describe how this software can improve the lives of its audience. - -Other things to include: - - - **Technology stack**: Indicate the technological nature of the software, including primary programming language(s) and whether the software is intended as standalone or as a module in a framework or other ecosystem. - - **Status**: Alpha, Beta, 1.1, etc. It's OK to write a sentence, too. The goal is to let interested people know where this project is at. This is also a good place to link to the [CHANGELOG](CHANGELOG.md). - - **Links to production or demo instances** - - Describe what sets this apart from related-projects. Linking to another doc or page is OK if this can't be expressed in a sentence or two. - - -**Screenshot**: If the software has visual components, place a screenshot after the description; e.g., - -![](https://raw.githubusercontent.com/cfpb/open-source-project-template/main/screenshot.png) +This YAML file is subject to sudden and breaking changes while the Small Business Lending project is in development, so use at your own risk. +![A rough diagram of the regtech-regex vision of a single YAML file sharing the same regular expression for validating data such as Research, Statistics, Supervision, Discount IDs across multiple use cases. The diagram shows a YAML object that contains a RSSD ID number along with a regex that ensures that the value is an integer. Two arrows point from the YAML: one arrow points to a file that has an RSSD ID that is 9999 with a green validation check mark, and the other arrow points toward a file that has an RSSD ID with a red invalid symbol of X](regtech-regex.svg) ## Dependencies -Describe any dependencies that must be installed for this software to work. -This includes programming languages, databases or other storage mechanisms, build tools, frameworks, and so forth. -If specific versions of other software are required, or known not to work, call that out. +This repo doesn't currently have any dependencies. Just a good old YAML file. ## Installation -Detailed instructions on how to install, configure, and get the project running. -This should be frequently tested to ensure reliability. Alternatively, link to -a separate [INSTALL](INSTALL.md) document. - -## Configuration - -If the software is configurable, describe it in detail, either here or in other documentation to which you link. +Import the `validations.yaml` file using the URL or via a package manager. ## Usage -Show users how to use the software. -Be specific. -Use appropriate formatting when showing code snippets. +Here's an example of an entry in the `validations.yaml` file: -## How to test the software +```yaml +rssd_id: + description: must be an integer + examples: + - '9999' + - '1' + link: https://regex101.com/r/l3SyQi/3 + regex: ^\d+$ +``` -If the software includes automated tests, detail how to run those tests. +Each entry should be snake case, with common acronyms and initialisms being acceptable. -## Known issues +Each entry should have 4 properties: description, examples, link, and regex. -Document any known significant shortcomings with the software. +- description: short description of how this value should be validated +- examples: an array of strings that are examples of values that would be validated as being correct +- link: a link to [regex101.com](https://regex101.com/) for live documentation and so devs can easily test the regular expression +- regex: the regular expression that validates the value ## Getting help -Instruct users how to get help with this software; this might include links to an issue tracker, wiki, mailing list, etc. - -**Example** - If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker. ## Getting involved -This section should detail why people should get involved and describe key areas you are -currently focusing on; e.g., trying to get feedback on features, fixing certain bugs, building -important pieces, etc. - -General instructions on _how_ to contribute should be stated with a link to [CONTRIBUTING](CONTRIBUTING.md). - +Think you might have a simple regular expression that relates to consumer finance that might be helpful? Create an issue! See [CONTRIBUTING](CONTRIBUTING.md) for more details. ----- +--- ## Open source licensing info + 1. [TERMS](TERMS.md) 2. [LICENSE](LICENSE) 3. [CFPB Source Code Policy](https://github.com/cfpb/source-code-policy/) - ----- +--- ## Credits and references -1. Projects that inspired you -2. Related projects -3. Books, papers, talks, or other sources that have meaningful impact or influence on this project +1. Screenshot uses icons from the [CFPB Design System](https://cfpb.github.io/design-system/foundation/iconography) and composed with [tldraw](https://www.tldraw.com/) diff --git a/opensource-checklist.md b/opensource-checklist.md deleted file mode 100644 index c4dca71..0000000 --- a/opensource-checklist.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -layout: base -title: "Open Source Checklist" ---- - -# Open Source Check List - -Prior to releasing a project to GitHub.com, walk through these items and ensure they are addressed. - -- **Has PII been removed?** - - Use [Clouseau](https://github.com/virtix/clouseau) for scanning source code. - - For an Open Source Release, attach the Clouseau output. - - If there are images, visually inspect each image to ensure there is no CFPB-specific information. - -- **Have security vulnerabilities been remediated?** - - Use the [OWASP Top 10](https://www.owasp.org/index.php/Top_10_2013) - - [National Vulnerability Database](http://nvd.nist.gov/) - - [SANS Swat Checklist](http://www.securingthehuman.org/developer/swat) - -- **Are we including any other open source products? If so, is there any conflict with our public domain release?** - -- **Is our `TERMS.md` included?** - -- **Is a `CHANGELOG.md` present and does it contain structured, consistently formatted recent history?** - - See and - - Some Inspiration: - -- **Are instructions for contributing included (`CONTRIBUTING.md`)?** - -- **Are installation instructions clearly written in the `README` _and_ tested on a clean machine?** - -- **Are all dependencies described in the `README`, `requirements.txt`, and/or `buildout.cfg`?** - -- **Are the API docs generated?** - -- **Are there unit tests?** - -- **If appplicable and possible, is it set up in TravisCI?** - -- **Have multiple people reviewed the code?** - -- **Is there a screenshot in the `README`, if applicable?** - - -## Copy this version to paste into a GitHub issue with live checkboxes: - -~~~ -- [ ] **Has PII been removed?** - - Use [Clouseau](https://github.com/virtix/clouseau) for scanning source code. - - If there are images, visually inspect each image to ensure there is no CFPB-specific information. -- [ ] **Have security vulnerabilities been remediated?** -- [ ] **Are we including any other open source products? If so, is there any conflict with our public domain release?** -- [ ] **Is our `TERMS.md` included?** -- [ ] **Is a `CHANGELOG.md` present and does it contain structured, consistently formatted recent history?** -- [ ] **Are instructions for contributing included (`CONTRIBUTING.md`)?** -- [ ] **Are installation instructions clearly written in the `README` _and_ tested on a clean machine?** -- [ ] **Are all dependencies described in the `README`, `requirements.txt`, and/or `buildout.cfg`?** -- [ ] **Are the API docs generated?** -- [ ] **Are there unit tests?** -- [ ] **If applicable and possible, is it set up in TravisCI?** -- [ ] **Have multiple people reviewed the code?** -- [ ] **Is there a screenshot in the `README`, if applicable?** -~~~ - ----- - - -## Take a look at the following projects as good models to follow: - - - [https://github.com/cfpb/qu](https://github.com/cfpb/qu) - - [https://github.com/cfpb/idea-box](https://github.com/cfpb/idea-box) - - [https://github.com/cfpb/hmda-tool](https://github.com/cfpb/hmda-tools) - - [https://github.com/cfpb/django-cache-tools](https://github.com/cfpb/django-cache-tools) diff --git a/regtech-regex.svg b/regtech-regex.svg new file mode 100644 index 0000000..81322d2 --- /dev/null +++ b/regtech-regex.svg @@ -0,0 +1,10 @@ +RSSD ID: 9999RSSD ID: 9999RSSD ID: Oops!RSSD ID: Oops!A RSSD ID must be an integer  +Regex: /^\d+$/A RSSD ID must be an integer  +Regex: /^\d+$/YAMLYAML \ No newline at end of file diff --git a/validations.yaml b/validations.yaml new file mode 100644 index 0000000..8cc4cee --- /dev/null +++ b/validations.yaml @@ -0,0 +1,36 @@ +email: + description: must conform to common email conventions using the W3C method of email validation which is only a subset of full RFC 5322 compliance as per https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) + examples: + - a-test-email-account@cfpb.gov + - ASuperCoolEmailAccount@cfpb.gov + link: https://regex101.com/r/bUsmeo/2 + regex: ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ +lei: + description: must be 20 characters and only contain A-Z, and 0-9 (no special characters) + examples: + - 123456789TESTBANK123 + - 123456789TESTBANK456 + - 123456TESTSUBBANK456 + link: https://regex101.com/r/5AaT18/6 + regex: ^[\dA-Z]{20}$ +rssd_id: + description: must be an integer + examples: + - '9999' + - '1' + link: https://regex101.com/r/l3SyQi/3 + regex: ^\d+$ +simple_us_phone_number: + description: a simple united states phone number pattern of 3 digits, followed, by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits + examples: + - 555-555-5555 + - 555-123-4567 + link: https://regex101.com/r/jt6ujJ/5 + regex: ^\d{3}-\d{3}-\d{4}$ +tin: + description: must be 2 digits, followed by a hyphen, followed by 7 digits + examples: + - 12-3456789 + - 98-7654321 + link: https://regex101.com/r/7op0LA/3 + regex: ^\d{2}-\d{7}$ From 4b45fac4e41c497106d0a0e28a8b74c7e12b9699 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Thu, 21 Mar 2024 20:43:21 -0700 Subject: [PATCH 2/8] feat(manifest): add the barest minimum package.json as a test --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..fd09163 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "name": "regtech-regex", + "license": "MIT", + "private": true, + "version": "1.0.0" +} \ No newline at end of file From 72cf5d542aeb3508304e4289c5ec0d16dff869a9 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Mon, 25 Mar 2024 20:59:21 -0700 Subject: [PATCH 3/8] fix(validations): lei examples and regex, references, comments --- validations.yaml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/validations.yaml b/validations.yaml index 8cc4cee..faabb8e 100644 --- a/validations.yaml +++ b/validations.yaml @@ -1,18 +1,23 @@ email: - description: must conform to common email conventions using the W3C method of email validation which is only a subset of full RFC 5322 compliance as per https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) + description: must conform to common email conventions using the W3C method of email validation which is only a subset of full RFC 5322 compliance examples: - a-test-email-account@cfpb.gov - ASuperCoolEmailAccount@cfpb.gov link: https://regex101.com/r/bUsmeo/2 + references: + - https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) regex: ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ lei: - description: must be 20 characters and only contain A-Z, and 0-9 (no special characters) + description: must be 20 characters and only contain A-Z, and 0-9 (no special characters) # See issue #3 for discussion about more comprehensive validations examples: - - 123456789TESTBANK123 - - 123456789TESTBANK456 - - 123456TESTSUBBANK456 - link: https://regex101.com/r/5AaT18/6 - regex: ^[\dA-Z]{20}$ + - 123400TESTBANK000192 + - 123400TESTBANK000289 + - 123400TESTSUBBANK147 + - 123400TESTSUBBANK244 + - TESTBANK123456789012 # See issue #3 for discussion about more comprehensive validations + link: https://regex101.com/r/ItOdOj/3 + references: + regex: ^[A-Z0-9]{18}\d{2}$ rssd_id: description: must be an integer examples: @@ -21,11 +26,12 @@ rssd_id: link: https://regex101.com/r/l3SyQi/3 regex: ^\d+$ simple_us_phone_number: - description: a simple united states phone number pattern of 3 digits, followed, by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits + description: must be a simple United States phone number pattern of 3 digits, followed, by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits examples: - 555-555-5555 - 555-123-4567 link: https://regex101.com/r/jt6ujJ/5 + references: regex: ^\d{3}-\d{3}-\d{4}$ tin: description: must be 2 digits, followed by a hyphen, followed by 7 digits @@ -33,4 +39,5 @@ tin: - 12-3456789 - 98-7654321 link: https://regex101.com/r/7op0LA/3 + references: regex: ^\d{2}-\d{7}$ From 20256f3dec5e96fd311e3e2dd2e561d999cb4026 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Mon, 25 Mar 2024 21:05:46 -0700 Subject: [PATCH 4/8] chore(validations): move into src folder --- validations.yaml => src/validations.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename validations.yaml => src/validations.yaml (100%) diff --git a/validations.yaml b/src/validations.yaml similarity index 100% rename from validations.yaml rename to src/validations.yaml From 24edc4ae608ba3e2638716ed476dd41c7b9a8e1d Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Mon, 25 Mar 2024 21:40:20 -0700 Subject: [PATCH 5/8] feat(validations): add error_text field --- src/validations.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/validations.yaml b/src/validations.yaml index faabb8e..40ed1e4 100644 --- a/src/validations.yaml +++ b/src/validations.yaml @@ -1,5 +1,6 @@ email: description: must conform to common email conventions using the W3C method of email validation which is only a subset of full RFC 5322 compliance + error_text: Must be a valid email address. examples: - a-test-email-account@cfpb.gov - ASuperCoolEmailAccount@cfpb.gov @@ -8,7 +9,8 @@ email: - https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) regex: ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ lei: - description: must be 20 characters and only contain A-Z, and 0-9 (no special characters) # See issue #3 for discussion about more comprehensive validations + description: must be 18 characters that only contain A-Z and 0-9 followed by a 2 digit # See issue #3 for discussion about more comprehensive validations + error_text: Must be a valid LEI of 20 characters that only contain A-Z and 0-9 (no special characters). examples: - 123400TESTBANK000192 - 123400TESTBANK000289 @@ -20,13 +22,15 @@ lei: regex: ^[A-Z0-9]{18}\d{2}$ rssd_id: description: must be an integer + error_text: Must be a number. examples: - '9999' - '1' link: https://regex101.com/r/l3SyQi/3 regex: ^\d+$ simple_us_phone_number: - description: must be a simple United States phone number pattern of 3 digits, followed, by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits + description: must be a simple United States phone number pattern of 3 digits, followed by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits + error_text: Must be a valid phone number in the format of 555-555-5555. examples: - 555-555-5555 - 555-123-4567 @@ -35,6 +39,7 @@ simple_us_phone_number: regex: ^\d{3}-\d{3}-\d{4}$ tin: description: must be 2 digits, followed by a hyphen, followed by 7 digits + error_text: Must be a valid TIN in the format of 12-3456789. examples: - 12-3456789 - 98-7654321 From 55e8ca147cb73bcebb40c4aa02013c08b7e9ad28 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Mon, 25 Mar 2024 21:45:56 -0700 Subject: [PATCH 6/8] fix(validations): fix typo in lei description --- src/validations.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validations.yaml b/src/validations.yaml index 40ed1e4..69df24d 100644 --- a/src/validations.yaml +++ b/src/validations.yaml @@ -9,7 +9,7 @@ email: - https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) regex: ^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$ lei: - description: must be 18 characters that only contain A-Z and 0-9 followed by a 2 digit # See issue #3 for discussion about more comprehensive validations + description: must be 18 characters that only contain A-Z and 0-9 followed by 2 digits # See issue #3 for discussion about more comprehensive validations error_text: Must be a valid LEI of 20 characters that only contain A-Z and 0-9 (no special characters). examples: - 123400TESTBANK000192 From 3076e9b38c39a96b2dd10252e06b64b7a83cc24c Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Mon, 25 Mar 2024 22:47:16 -0700 Subject: [PATCH 7/8] fix(validations): update readme, add a missing references, add newline to package.json --- README.md | 8 ++++++-- package.json | 2 +- src/validations.yaml | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aba385e..79005fc 100644 --- a/README.md +++ b/README.md @@ -21,20 +21,24 @@ Here's an example of an entry in the `validations.yaml` file: ```yaml rssd_id: description: must be an integer + error_text: Must be a number. examples: - '9999' - '1' link: https://regex101.com/r/l3SyQi/3 + references: regex: ^\d+$ ``` Each entry should be snake case, with common acronyms and initialisms being acceptable. -Each entry should have 4 properties: description, examples, link, and regex. +Each entry should have the following properties: -- description: short description of how this value should be validated +- description: a short description of how this value should be validated +- error_text: a user-friendly message that could be displayed on a frontend form validation - examples: an array of strings that are examples of values that would be validated as being correct - link: a link to [regex101.com](https://regex101.com/) for live documentation and so devs can easily test the regular expression +- references: an array of links to external documentation - regex: the regular expression that validates the value ## Getting help diff --git a/package.json b/package.json index fd09163..93836b5 100644 --- a/package.json +++ b/package.json @@ -3,4 +3,4 @@ "license": "MIT", "private": true, "version": "1.0.0" -} \ No newline at end of file +} diff --git a/src/validations.yaml b/src/validations.yaml index 69df24d..0a4d227 100644 --- a/src/validations.yaml +++ b/src/validations.yaml @@ -27,6 +27,7 @@ rssd_id: - '9999' - '1' link: https://regex101.com/r/l3SyQi/3 + references: regex: ^\d+$ simple_us_phone_number: description: must be a simple United States phone number pattern of 3 digits, followed by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits From c351244a4bb8f998eb3f54e00ece05c241ac15a9 Mon Sep 17 00:00:00 2001 From: Bill Himmelsbach Date: Tue, 26 Mar 2024 08:27:47 -0700 Subject: [PATCH 8/8] fix(references): remove references when null --- src/validations.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/validations.yaml b/src/validations.yaml index 0a4d227..7c54b09 100644 --- a/src/validations.yaml +++ b/src/validations.yaml @@ -18,7 +18,6 @@ lei: - 123400TESTSUBBANK244 - TESTBANK123456789012 # See issue #3 for discussion about more comprehensive validations link: https://regex101.com/r/ItOdOj/3 - references: regex: ^[A-Z0-9]{18}\d{2}$ rssd_id: description: must be an integer @@ -27,7 +26,6 @@ rssd_id: - '9999' - '1' link: https://regex101.com/r/l3SyQi/3 - references: regex: ^\d+$ simple_us_phone_number: description: must be a simple United States phone number pattern of 3 digits, followed by a hyphen, followed by 3 digits, followed by a hyphen, followed by 4 digits @@ -36,7 +34,6 @@ simple_us_phone_number: - 555-555-5555 - 555-123-4567 link: https://regex101.com/r/jt6ujJ/5 - references: regex: ^\d{3}-\d{3}-\d{4}$ tin: description: must be 2 digits, followed by a hyphen, followed by 7 digits @@ -45,5 +42,4 @@ tin: - 12-3456789 - 98-7654321 link: https://regex101.com/r/7op0LA/3 - references: regex: ^\d{2}-\d{7}$