Pre-deploy Validation (tcb validate)
Version Requirement
tcb validate is available since v3.8.0.
tcb validate checks whether the project's cloudbaserc.json (v2.1) config is valid, resource directories exist, and resource references are consistent — catching problems early before deployment. It is the companion command to Declarative Deployment (tcb deploy).
Quick Start
# Validate cloudbaserc.json in the current directory
tcb validate
# Specify a config file
tcb validate --config-file ./config/prod.json
# Validate a specific mode (applies envOverrides)
tcb validate --mode dev
On success, it prints a resource overview and exits with code 0:
Config version: 2.1
Resource overview: 1 cloud function, 1 static hosting, 0 databases, 2 gateway routes
Validation Items
| Item | Description | Example |
|---|---|---|
| Schema version | Config conforms to v2.1 Schema (valid fields, no extra properties) | gateway.routes rejects unknown fields like cdnType |
| envId | Config must include envId | - |
| requiredEnv | Required env vars declared in requiredEnv are provided | - |
| Resource directories | Function dirs / hosting roots exist | functions/pay-common/ missing is an error |
| Consistency | Gateway target references exist in config | target: "function:pay-common" but the function is not defined |
Output and Exit Codes
| Case | Output | Exit code |
|---|---|---|
| Valid | Config version + resource overview | 0 |
| Invalid | Error list (field + fix suggestion) | 1 |
Errors (2)
- gateway.routes.0: config does not conform to v2.1 Schema: should NOT have additional properties
Fix: check the gateway.routes.0 field
- gateway.routes.1: config does not conform to v2.1 Schema: should NOT have additional properties
Fix: check the gateway.routes.1 field
Relationship with tcb deploy
tcb deployalso performs a lightweight config guard (envIdpresence, valid config)- It is recommended to run
tcb validatebeforetcb deployin CI to surface config issues early - Full validation (Schema/dirs/consistency) is authoritative in
tcb validate