Data Model Validation
Validate a set of custom field values against a workspace's data model. Validation only considers non-system client fields; system fields are skipped.
Auth: Bearer token — workspace member (enforced by workspaceGuard).
Validate Custom Fields
POST /wallethero-api/workspace/:workspaceId/data-model/validate
Checks the provided custom_fields against the non-system field definitions of the workspace. Returns whether the payload is valid along with a list of human-readable error messages.
Auth: Bearer token — workspace member.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
workspaceId | string (UUID) | Workspace identifier |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
custom_fields | object | No | Map of field_name → value to validate. Defaults to {} if omitted. |
Example Request
curl -X POST "https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID/data-model/validate" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"custom_fields": {
"points": 1500,
"tier": "Gold",
"birthday": "2024-01-15"
}
}'Response (200) — Valid
{
"data": {
"valid": true,
"errors": []
}
}Response (200) — Invalid
The response is always HTTP 200; check the valid flag and errors array. Error messages reference the field's field_label.
{
"data": {
"valid": false,
"errors": [
"Field \"Membership Tier\" must be one of: Bronze, Silver, Gold, Platinum",
"Field \"Points Balance\" must be a number",
"Field \"Loyalty Number\" is required"
]
}
}SDK
const result = await wh.workspaces.validateCustomFields(workspaceId, {
points: 1500,
tier: "Diamond", // not in allowed_values
});
if (!result.valid) {
console.log("Validation failed:", result.errors);
}Validation Rules
Each non-system field is checked as follows. A field whose value is undefined or null is skipped (unless required).
| Field Type | Rule |
|---|---|
string | No type check beyond the required/allowed rules below. |
number | Must be a number, or a value that coerces to a number. Otherwise: Field "<label>" must be a number. |
date | Must be a string matching YYYY-MM-DD and be parseable. Otherwise: Field "<label>" must be a valid date (or ...must be a valid date string if not a string). |
multiselect | The value must be one of the field's allowed_values. Otherwise: Field "<label>" must be one of: <allowed values>. |
image | Must be a string that is either a Directus file UUID or an http(s):// URL. Otherwise: Field "<label>" must be a Directus file UUID or an http(s):// URL. |
Required Fields
If a field has is_required: true and the submitted value is undefined, null, or an empty string (""), validation fails with:
Field "<label>" is requiredAllowed Values (multiselect)
For multiselect fields, the submitted value must match one of allowed_values:
// Field definition
{ "field_name": "tier", "field_type": "multiselect", "allowed_values": ["Bronze", "Silver", "Gold"] }
// Valid
{ "tier": "Gold" }
// Invalid -> "Field \"...\" must be one of: Bronze, Silver, Gold"
{ "tier": "Diamond" }Get Default Values
GET /wallethero-api/workspace/:workspaceId/data-model/defaults
Returns the default values for non-system fields. See Get Default Values on the Fields page for full details.
Auth: Bearer token — workspace member.
Example Request
curl "https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID/data-model/defaults" \
-H "Authorization: Bearer YOUR_TOKEN"Response (200)
{
"data": {
"points": "0",
"tier": "Bronze"
}
}SDK
const defaults = await wh.workspaces.getDataModelDefaults(workspaceId);
// Merge defaults when validating or creating client custom fields
const result = await wh.workspaces.validateCustomFields(workspaceId, {
...defaults,
points: 500,
});