prisma validate
Validate your Prisma schema for syntax errors, configuration issues, and potential problems.Usage
Options
Display help message.Alias:
-hCustom path to your Prisma config file.
Custom path to your Prisma schema.
Examples
Basic validation
Validate custom schema
Validate with custom config
What Gets Validated
Thevalidate command checks:
1. Syntax Errors
- Proper Prisma schema syntax
- Correct use of keywords and attributes
- Valid field types and modifiers
2. Schema Structure
- Required datasource and generator blocks
- Valid model definitions
- Proper relation syntax
3. Relations
- Valid relation fields
- Correct referential actions
- Proper foreign key definitions
4. Native Database Types
- Valid native type mappings for the provider
- Supported database-specific features
5. Attributes and Directives
- Correct attribute syntax
- Valid attribute arguments
- Compatible attribute combinations
6. Configuration
- Valid datasource URL
- Supported provider
- Valid generator configuration
Linting Warnings
In addition to errors, validation also shows linting warnings:Exit Codes
0- Schema is valid1- Schema has errors
Integration with Development Workflow
Pre-commit Hook
Add validation to your pre-commit hooks:CI/CD Pipeline
IDE Integration
The Prisma VS Code extension validates your schema in real-time as you type.Common Validation Errors
Missing @id
@id field:
Invalid Relation
Unsupported Type
Multi-File Schema Validation
When using multi-file schemas,validate checks all schema files:
Related Commands
prisma format- Format your schemaprisma generate- Generate Prisma Client (also validates)prisma migrate dev- Create migrations (also validates)