Data Validation
Validate actor and organization data integrity with the validate-actors CLI.
Overview
Ensures actor affiliations reference valid organizations before game generation.
Usage
bun run command:validateValidation Checks
- Schema Validation - Zod schemas for actors and organizations
- Affiliation Integrity - All affiliations must reference existing orgs
- Required Fields - Checks for
realNameandusername - Organization IDs - Validates all organization references
Output
Success
Validating 50 actors against 25 organizations...
All actor affiliations are valid!
{ actorsChecked: 50, organizationsVerified: 25, warnings: 0 }Warnings (Non-Fatal)
WARNINGS:
Actor1 (actor1) missing 'realName' field
Actor2 (actor2) missing 'username' fieldErrors (Fatal)
VALIDATION ERRORS:
Actor1 (actor1) has invalid affiliation: "nonexistent-org"
Actor2 (actor2) has invalid affiliation: "deleted-company"
Found 2 error(s)Exit code: 1
Data Source
Reads from public/data/actors.json (index file) and individual actor/organization files:
public/data/
├── actors.json # Index with references
├── actors/ # Individual actor JSON files
│ ├── actor1.json
│ └── ...
└── organizations/ # Individual organization JSON files
├── org1.json
└── ...Example actor file (public/data/actors/actor1.json):
{
"id": "actor1",
"name": "John Doe",
"realName": "John Doe",
"username": "jdoe",
"affiliations": ["org1", "org2"]
}Integration
The validation is automatically run by generate-game before generation:
// In generate-game.ts
await validateActorsData();
// Will exit if validation failsFixing Errors
Invalid Affiliation
Actor1 has invalid affiliation: "old-org"Solution: Either:
- Create a new organization file in
public/data/organizations/and add the reference toactors.json - Remove the affiliation from the actor file in
public/data/actors/ - Update the affiliation ID
Missing Required Fields
Actor1 missing 'realName' fieldSolution: Add the missing field:
{
"id": "actor1",
"name": "John Doe",
"realName": "John Doe", // Add this
"username": "jdoe",
"affiliations": []
}Exit Codes
- 0 - Validation passed (warnings OK)
- 1 - Validation failed (errors found)
Use in scripts:
if bun run command:validate; then
echo "Validation passed"
bun run command:generate
else
echo "Validation failed"
exit 1
fiLast updated on