Database > Schemas & Validation
Database > Schemas & ValidationKroxt BaaS SDK v1.0.5

Schemas & Validation

Unlike raw schemaless MongoDB, Kroxt enforces strict validation rules configured inside the collection schema designer.

Validation Process

When a client calls `collection("todos").create()`, the payload parameters are checked against the stored type map. If fields are missing, have incorrect types, or contain undeclared keys in a strict collection, the request is rejected with a `400 Bad Request` schema validation payload.

Schema Definition Object structure:
schema.json
1
2
3
4
5
6
7
8
9
10
11
12
13
// Schemas are defined in the dashboard UI. Below is the JSON representation:
{
  "name": "todos",
  "fields": [
    { "name": "text", "type": "text", "required": true },
    { "name": "completed", "type": "boolean", "required": true, "defaultValue": false },
    { "name": "priority", "type": "number", "required": false }
  ],
  "rules": {
    "read": "public",
    "write": "authenticated"
  }
}