Synopsis
Description
Thevalidate command checks schema files for:
- Syntax errors - Malformed schema syntax
- Type errors - Invalid or unknown types
- Reference errors - Missing entities or fields
- Constraint errors - Invalid primary keys, unique constraints
- Circular dependencies - Detect entity reference cycles
schema.cham in the current directory.
Arguments
string
Path to schema file to validateDefault:
schema.cham in current directoryFlags
boolean
default:"false"
Show detailed validation checks passed
Examples
Validate Default Schema
Validate Specific File
Validation Errors
Syntax Error
schemas/invalid.cham:Missing Primary Key
schemas/no-pk.cham:Invalid Reference
schemas/bad-ref.cham:Circular Dependency
schemas/circular.cham:Valid Schema Example
schemas/blog.cham:File Not Found
Validation Checks
The validator performs these checks:1. Syntax Validation
- Correct entity declarations
- Valid field syntax
- Proper use of keywords (primary, unique, default)
2. Type Checking
- All types are recognized (uuid, string, int, bool, timestamp, etc.)
- Array types are properly declared
3. Semantic Validation
- Each entity has a primary key
- Referenced entities exist
- Foreign key types match target primary keys
- No duplicate field names within an entity
4. Constraint Validation
- Unique constraints are properly defined
- Default values match field types
- Indexes reference existing fields
5. Relationship Validation
- Foreign key relationships are valid
- No unresolvable circular dependencies
Exit Codes
0- Schema is valid1- Validation failed or file not found
Integration with Migrate
Validation is automatically performed during migration:Best Practices
1. Validate Before Committing
2. Validate All Schemas
If you have multiple schema files:3. CI/CD Integration
Troubleshooting
Validation Passes but Migration Fails
Thevalidate command only checks syntax and semantics, not database compatibility.
Use migrate --dry-run to check generated SQL:
Multiple Schema Files
To validate across multiple files, usemigrate --check:
schema.paths.
See Also
chameleon migrate- Apply migrations (includes validation)chameleon init- Initialize project with example schema- Schema Reference - Learn schema syntax
- Schema Types - Available field types