Skip to main content
Clinia’s profiles and relationship definitions let you attach validation rules to every property. These rules complement the built-in type validators described in the base data types and Clinia complex types pages.

Rule catalog

The rules array accepts multiple validation criteria:
Validation RuleFormatData Types
requiredboolean (true or false)All fields (including arrays and custom objects)
min & max (on value)integer or decimalNumeric data types
min & max (on length)integerString-based types or arrays
enumMust match property typeNumeric or string-based types
patternRegex stringString-based types
Rules are evaluated in order. You can mix multiple constraints within the same property to achieve stricter contracts.

Required fields

Marking a property as required enforces that the key must be present and not null:
{
  "properties": {
    "propertyName": {
      "type": "symbol",
      "rules": [
        {
          "required": true
        }
      ]
    }
  }
}

Numeric data types

integer and decimal properties can enforce value ranges or enumerations:
{
  "properties": {
    "age": {
      "type": "integer",
      "rules": [
        {
          "required": true,
          "min": 18,
          "max": 120
        }
      ]
    },
    "taxRate": {
      "type": "decimal",
      "rules": [
        {
          "enum": [10.5, 12.2, 15.05]
        }
      ]
    }
  }
}

String data types

String-based types (symbol, code, markdown, uri, url, xhtml) can combine length, enumeration, and pattern rules:
{
  "properties": {
    "comment": {
      "type": "symbol",
      "rules": [
        {
          "min": 5,
          "max": 120
        }
      ]
    },
    "gender": {
      "type": "code",
      "rules": [
        {
          "enum": ["male", "female", "non-binary"]
        }
      ]
    },
    "email": {
      "type": "symbol",
      "rules": [
        {
          "pattern": "^[\\w\\-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"
        }
      ]
    }
  }
}
Clinia evaluates regular expressions using the ECMAScript flavor. Escape backslashes accordingly: ^[\\w\\-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$.

Arrays

You can constrain both the array itself and its items:
{
  "properties": {
    "phones": {
      "type": "array",
      "rules": [
        {
          "required": true,
          "min": 2,
          "max": 10
        }
      ],
      "items": {
        "type": "contactpoint",
        "properties": {
          "value": {
            "rules": [
              {
                "required": true
              }
            ]
          }
        }
      }
    }
  }
}
  • required forces the array to be present (it can still be empty).
  • min/max target the number of elements.
  • Nested rules apply to every item in the array.

Objects and complex types

Object properties (custom object types or Clinia complex types like address, contactpoint) only accept required at the top level. To validate sub-fields, apply rules directly on nested properties:
{
  "properties": {
    "address": {
      "type": "address",
      "rules": [
        { "required": true }
      ],
      "properties": {
        "city": {
          "rules": [
            {
              "pattern": "^[A-Za-z ]+$",
              "required": true
            }
          ]
        }
      }
    }
  }
}

Next steps:
I