Version: 1.0.0
Category: validation
Schema: JSON Schema Draft-07
Description: Validation rules, patterns, and validators for AI agents to validate API requests and responses. See schemas/formats.md for format specifications.
A validation rule definition.
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Unique rule identifier |
| name | string | Yes | Rule name |
| field | string | No | Field to validate (dot notation) |
| type | string | Yes | Validation type: required, type, format, range, pattern, or custom |
| value | any | No | Validation value (depends on type) |
| message | string | No | Error message if validation fails |
A validation pattern composed of multiple rules.
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Pattern identifier |
| name | string | Yes | Pattern name |
| description | string | No | Pattern description |
| rules | array of ValidationRule | Yes | Validation rules for this pattern |
| Property | Type | Default | Description |
|---|---|---|---|
| required | boolean | true | Whether field is required |
| type | string | string |
Allowed types: string, number |
| pattern | string | Regex pattern for player ID format |
| Property | Type | Default | Description |
|---|---|---|---|
| required | boolean | true | Whether field is required |
| type | string | string |
Allowed type: string |
| pattern | string | Regex pattern for planet ID format (e.g., \d+-\d+) |
| Property | Type | Default | Description |
|---|---|---|---|
| required | boolean | true | Whether field is required |
| type | string | string |
Allowed type: string |
| pattern | string | Regex pattern for blockchain address (e.g., ^structs1[a-z0-9]{38}$) |
| Property | Type | Description |
|---|---|---|
| expected | array of integer | Expected status codes |
| retryable | array of integer | Retryable status codes (5xx) |
Required fields by endpoint, defined as key-value pairs where the key is the endpoint path and the value is an array of required field names.
| Property | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Whether schema validation is enabled |
| strict | boolean | false | Strict schema validation (reject unknown fields) |
| Property | Type | Default | Description |
|---|---|---|---|
| required | boolean | true | Whether message type is required |
| pattern | string | Message type pattern (e.g., /structs.structs.Msg.*) |
| Property | Type | Default | Description |
|---|---|---|---|
| required | boolean | true | Whether creator address is required |
| format | string | blockchain-address |
Expected format |
| Property | Type | Default | Description |
|---|---|---|---|
| min | integer | 200000 | Minimum gas limit |
| max | integer | 10000000 | Maximum gas limit |
ID: player-query
Validation for player query endpoints.
| Rule ID | Rule Name | Field | Type | Value | Message |
|---|---|---|---|---|---|
| player-id-required | Player ID Required | id | required | Player ID is required | |
| player-id-format | Player ID Format | id | pattern | ^1-[0-9]+$ |
Player ID must be in format 1-X where X is the player index (e.g., 1-11) |
ID: planet-query
Validation for planet query endpoints.
| Rule ID | Rule Name | Field | Type | Value | Message |
|---|---|---|---|---|---|
| planet-id-required | Planet ID Required | id | required | Planet ID is required | |
| planet-id-format | Planet ID Format | id | pattern | ^2-[0-9]+$ |
Planet ID must be in format 2-X where X is the planet index (e.g., 2-1) |
ID: transaction
Validation for transaction submission.
| Rule ID | Rule Name | Field | Type | Value | Message |
|---|---|---|---|---|---|
| message-type-required | Message Type Required | body.messages[].@type | required | Message type is required | |
| creator-required | Creator Required | body.messages[].creator | required | Creator address is required | |
| creator-format | Creator Format | body.messages[].creator | format | blockchain-address |
Creator must be a valid blockchain address |
| gas-limit-range | Gas Limit Range | auth_info.fee.gas_limit | range | min: 200000, max: 10000000 | Gas limit must be between 200000 and 10000000 |
Standalone validators for common field types.
| Validator | Type | Pattern | Description |
|---|---|---|---|
| playerId | string | ^1-[0-9]+$ |
Player ID must be in format 1-X where X is the player index (e.g., 1-11). Type 1 = Player. |
| planetId | string | ^2-[0-9]+$ |
Planet ID must be in format 2-X where X is the planet index (e.g., 2-1). Type 2 = Planet. |
| blockchainAddress | string | ^structs1[a-z0-9]{38}$ |
Blockchain address must start with structs1 and be 45 characters |
| structId | string | ^5-[0-9]+$ |
Struct ID must be in format 5-X where X is the struct index (e.g., 5-42). Type 5 = Struct. |
| fleetId | string | ^9-[0-9]+$ |
Fleet ID must be in format 9-X where X is the fleet index (e.g., 9-11). Type 9 = Fleet. |
| guildId | string | ^0-[0-9]+$ |
Guild ID must be in format 0-X where X is the guild index (e.g., 0-1). Type 0 = Guild. |
| Endpoint | Required Fields |
|---|---|
/structs/player/{id} |
Player, gridAttributes, playerInventory, halted |
/structs/planet/{id} |
Planet, gridAttributes, planetAttributes |
/structs/guild/{id} |
Guild |
/api/player/{player_id} |
player |
/api/planet/{planet_id} |
planet |
| Category | Codes |
|---|---|
| Expected | 200 |
| Retryable | 500, 502, 503, 504 |
| Client Errors | 400, 401, 403, 404 |
| Server Errors | 500, 502, 503, 504 |
ID: struct-build-validation
Validation requirements for MsgStructBuild.
| Check ID | Name | Query | Field | Expected | Condition | Message |
|---|---|---|---|---|---|---|
| player-online | Player Online | GET /structs/player/{playerId} |
halted | false | Player must be online (not halted) | |
| command-ship-online | Command Ship Online | GET /structs/fleet/{fleetId} |
locationType = planet | Command Ship must be built and online in fleet | ||
| fleet-on-station | Fleet On Station | GET /structs/fleet/{fleetId} |
status | onStation | locationType = planet | Fleet must be on station (not away) |
| sufficient-power | Sufficient Power | GET /structs/player/{playerId} |
gridAttributes.power | Must have sufficient power capacity |
GET /structs/structID: planet-explore-validation
Validation requirements for MsgPlanetExplore.
| Check ID | Name | Query | Field | Expected | Message |
|---|---|---|---|---|---|
| current-planet-empty | Current Planet Empty | GET /structs/planet/{currentPlanetId} |
gridAttributes.ore | 0 | Current planet must have 0 ore before exploring new planet |
| player-online | Player Online | GET /structs/player/{playerId} |
halted | false | Player must be online |
GET /structs/planet_by_player/{playerId}ID: broadcast-no-result
Transaction shows broadcast status but action didn’t happen.
broadcast but game state unchangedDiagnosis:
schemas/actions.mdSolution:
Prevention:
ID: command-ship-not-online
Attempting to build on planet without Command Ship online.
MsgStructBuild broadcasts but struct not created on planetDiagnosis:
GET /structs/fleet/{fleetId}online (not just materialized)onStationSolution:
MsgStructBuild)MsgStructBuildComplete)Reference: See schemas/actions.md MsgStructBuild for complete requirements.
ID: insufficient-power
Attempting to build struct without sufficient power capacity.
MsgStructBuild broadcasts but struct not createdDiagnosis:
GET /structs/player/{playerId}gridAttributes.power (current power)Solution:
ID: planet-not-empty
Attempting to explore new planet while current planet has ore.
MsgPlanetExplore broadcasts but planet ownership unchangedDiagnosis:
GET /structs/planet/{planetId}gridAttributes.oreSolution:
POST /cosmos/tx/v1beta1/txsbroadcast statusbroadcast statusIMPORTANT: Transaction status broadcast does NOT mean action succeeded. Validation happens on-chain after broadcast. Always verify game state to confirm action occurred.
schemas/actions.md - Complete action requirementspatterns/validation-patterns.md - Detailed validation patternsprotocols/error-handling.md - Error handling patterns