Validations
Validations are the rules Grunddata applies whenever a record is saved. They are the difference between a spreadsheet and governed business data.
Validations are expressed using JSON Schema, but you do not have to write JSON — the web app builds the schema from a form.
Two levels of validation
Section titled “Two levels of validation”| Level | Attached to | Use when |
|---|---|---|
| Attribute | A single attribute | The rule concerns one value on its own |
| Table | The whole table | The rule compares two attributes with each other |
Attribute level rules
Section titled “Attribute level rules”Open an attribute and add a validation. The available rules depend on the datatype.
String attributes
Section titled “String attributes”| Rule | Meaning | Example |
|---|---|---|
| Starts with | Value must begin with a prefix | Account numbers must start with 4 |
| Ends with | Value must end with a suffix | Codes must end with -SE |
| Min length | Minimum number of characters | At least 3 characters |
| Regex pattern | Value must match a regular expression | ^[A-Z]{3}$ for a three-letter code |
| One of (list) | Value must be one of an explicit list | NOM, MTM, INT |
Numeric attributes (integer, decimal)
Section titled “Numeric attributes (integer, decimal)”| Rule | Meaning | Example |
|---|---|---|
| Number comparison | Greater than / less than a fixed value | Limit must be > 0 |
| Multiple of | Value must be a multiple of a number | Amounts in whole thousands |
| One of (list) | Value must be one of an explicit list | 1, 5, 10 |
Table level rules: comparing two attributes
Section titled “Table level rules: comparing two attributes”Some rules cannot live on a single attribute — they are about the relationship between two. Open the table and use its validation editor to add a comparison.
Each comparison rule has a left attribute, an operator and a right attribute:
| Operator | Meaning |
|---|---|
> |
is greater than |
>= |
is greater than or equal to |
< |
is less than |
<= |
is less than or equal to |
!= |
is not equal to |
The two attributes must be of a compatible family:
| Family | Datatypes | Allowed operators |
|---|---|---|
| Number | integer, decimal |
all |
| Temporal | date, datetime |
all |
| String | string |
!= only |
Examples
Section titled “Examples”| Rule | Reads as |
|---|---|
valid_to > valid_from |
The end of a period must be after its start |
soft_limit <= hard_limit |
A soft limit may not exceed the hard limit |
primary_contact != backup_contact |
The two contacts must be different people |
Preview before you enforce
Section titled “Preview before you enforce”The validation editor has a Preview action. It runs the proposed rule against the records already in the table and reports:
- How many records are valid.
- How many would fail.
- A sample of the failing records, with
Code,Nameand the specific failure messages.
What users see when validation fails
Section titled “What users see when validation fails”A save is all-or-nothing per record. When a record fails:
- The record is not written. No partial save, no truncated value.
- An entry is added to the record audit with status
errorand a human-readable message. - In the web app, the message appears directly in the record form.
- In Excel and Google Sheets, the failing rows are reported back after the upload so the user can correct them and try again.
Designing a validation strategy
Section titled “Designing a validation strategy”-
Start with attribute properties. Required, unique and max length cover a surprising amount, and they cost nothing.
-
Replace free text with domain tables wherever a fixed set of values exists. This removes whole classes of error rather than catching them.
-
Add attribute validations for format rules that a lookup cannot express — patterns, ranges, minimum lengths.
-
Add table validations for cross-field business rules.
-
Preview each rule against real data before saving it.