Skip to main content
Skip table of contents

VA Forms Library - How to make a required form field optional

In some cases, you may want to make a form field fully optional, which requires updates to vets-json-schema, vets-website, and vets-api.

Making a required form field optional

Step 1: Update vets-json-schema

  1. Open a PR in vets-json-schema

  2. Remove the field from the required property in your application’s specific schema. You’ll have to remove it twice; once from the schema JSON file, and once from the schema JavaScript file. (You’ll also increment the package.json version)

Important notes: If you're using a regex pattern to validate a field and you wish to make that field optional, you’ll need to adjust the regex in vets-json-schemato accept an empty string or else the user won’t be able to advance without fulfilling the pattern required by the regex, even though the field won’t be marked as required.

Step 2: Update vets-website

  1. Make your changes in vets-website.

  2. To test your changes locally, you can update your package.json and yarn.lock to point to the commit SHA of your vets-json-schema commit, and update the version referenced in the yarn.lock, and then yarn install.

Step 3: Update vets-api

  1. Make a PR for vets-api that references the new vets-json-schema version in the gemfile.lock.

Tips and testing

You’ll want to try to merge your PRs as closely together as possible so that the schema version matches across backend and frontend. One tip is to merge after the production deploy for the day so you can have a longer period of time to test on Staging.

Testing notes

For making a field optional, you’ll want to remove it from any “minimal” tests in vets-website and the schema specs in vets-json-schema to make sure that the tests work without the field.


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.