Skip to content

Commit

Permalink
docs: Added expressions for validating if a field is empty or not (#4353
Browse files Browse the repository at this point in the history
)

* Updated docs to include info regarding on validating is field is empty or not

* Rewrote explanation a bit to include reference to required
  • Loading branch information
svandenhoek authored Oct 14, 2024
1 parent be6a482 commit 4958f7f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/molgenis/use_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ expression itself is shown. Otherwise, the return value of the expression will b
| `/^([a-z]+)$/.test(name)` | Application of validation rule failed: /^([a-z]+)$/.test(name) |
| `if(!/^([a-z]+)$/.test(name))'name should contain only lowercase letters'` | Application of validation rule failed: name should contain only lowercase letters |

Special attention needs to be paid when validating if a field is empty or not (as filled in fields that get emptied are different from never filled in fields).
While [required](#required) should be used to ensure a field itself is filled, when creating expressions (that include other fields), use the following:

| validation | functioning |
|--------------------------|-----------------------------------|
| `columnName?.length > 0` | Field 'columnName' must be filled |
| `!(columnName?.length)` | Field 'columnName' must be empty |

Visible expressions must return a value that is not false or undefined, otherwise the column stays hidden in the user interface. In the event that javascript
throws an exception, this is shown in user interface/error message. For example:

Expand Down

0 comments on commit 4958f7f

Please sign in to comment.