Skip to content

Commit

Permalink
fix: document validation technique for required strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rstyan committed Feb 3, 2025
1 parent 355558a commit fea80c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 14 additions & 0 deletions docs/tutorials/form-service/building-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ Sometimes a specific answer to a question will influence the flow of the form. A

Jsonforms automatically handles basic input validation, such as ensuring required fields are filled in, dates are formatted correctly, or that numbers are, indeed, numbers. More sophisticated validation is also possible; you can add [custom error messages](https://jsonforms.io/docs/validation/) or even [integrate a custom AJV validator](https://jsonforms.io/docs/validation/) to [harness the full power of AJV](https://ajv.js.org/), which gives you complete control over validation.

#### Required Fields

There is a known issue in jsonforms that allows an empty string to satisfy the required validation rule. To work around this, you should also add a minimum length of 1 to required string fields, e.g.

```json
{
"firstName": {
"type": "string",
"minLength": 1
},
"required": ["firstName"]
}
```

### Repeating Items

You will sometimes need to capture [lists of information](/adsp-monorepo/tutorials/form-service/repeated-items.html) in a form. Lists contain a variable number of items, each containing the necessary details. For example, an application for a Farmers Market License may require list of vendors, each with contact information, a classification, and their expected yearly revenue. Users are able to add one item at a time and fill in the details as needed.
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/form-service/cheat-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Note: in some UI schemas you will see "ComponentProps" in the options element. C

### Common data formats {#target-common-formats}

Here are some out-of-the-box formats that not only render with the correct input widget, but ensure that the data provided by users is valid.
Here are some out-of-the-box formats that not only render with the correct input widget, but ensure that the data provided by users is valid. NOTE: There is a known issue in jsonforms that allows an empty string to satisfy the required validation rule. To work around this, you should also add a minimum length of 1 to required string fields (see Limited text with required validation) below.

<table>
<tr>
Expand Down
5 changes: 2 additions & 3 deletions docs/tutorials/form-service/form-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ https://form.adsp-uat.alberta.ca/afids/Farmers-Market-License-Application

### Users

Currently only GoA personnel are able to log-in and use the _Form-App_, although ADSP will be implementing other, secure techniques to enable other Albertans to use the product, including
Forms can be configured to allow only those people with GoA or Alberta.ca credentials to access and fill them in. This gives users the best experience, as they will be able to fill in the information over several sessions, as needed. In addition, they will be able to initiate online conversations with form administrators if they have questions.

- use of My Alberta Digital ID
- use of email and verification codes
However, you can also configure a form to allow anonymous access. Anyone will be able to fill in and submit a form, without logging in. In this case, they will have to complete the form in one session, and they will not have access to the "chat" capability.

### Security

Expand Down

0 comments on commit fea80c9

Please sign in to comment.