Naming and Validation
Why Naming Matters¶
VDL schemas are used to generate code in different languages. Consistent names make generated output predictable and pleasant to use.
The analyzer reports diagnostics when names do not follow the expected convention.
Naming Conventions¶
| Element | Convention | Examples |
|---|---|---|
| Types | PascalCase |
User, OrderItem |
| Enums | PascalCase |
OrderStatus, Region |
| Enum members | PascalCase |
Pending, InProgress |
| Fields | camelCase |
userId, createdAt |
| Constants | camelCase |
apiVersion, maxPageSize |
| Annotations | camelCase |
deprecated, generateCode |
PascalCase¶
PascalCase starts with an uppercase letter and does not use underscores.
Good:
Avoid:
camelCase¶
camelCase starts with a lowercase letter and does not use underscores.
Good:
Avoid:
File Names¶
Regular schema files should match:
Examples:
The configuration file must be named:
Global Name Uniqueness¶
Top-level type, enum, and constant names share one global namespace.
Invalid:
Use unique names across declarations.
Duplicate Fields¶
Fields must be unique within each object or inline object.
Invalid:
Undefined References¶
Every type reference must point to a declared type, enum, or primitive.
Invalid:
Fix it by declaring Address or including the file that declares it.
Cycles¶
VDL rejects required type cycles.
Invalid:
Break the cycle with an optional field.
Practical Checklist¶
Before generating code, check that:
- file names are lowercase with underscores when needed
- types and enums use PascalCase
- fields and constants use camelCase
- all referenced types and enums exist
- object fields are unique
- enum member names and values are unique
- required type references do not form cycles
- spreads do not conflict or form cycles