tcb validate
Validate that the project cloudbaserc.json is well formed, that resource directories exist, and that resource references are consistent, surfacing configuration problems before deployment.
v3.8.0+
tcb validate has been available since v3.8.0.
Usage
tcb validate [options]
Parameters
| Parameter | Required | Description | Default |
|---|---|---|---|
--config-file <path> | No | Path to the configuration file | cloudbaserc.json in the project root |
--mode <mode> | No | Validate after applying envOverrides.<mode> | — |
Examples
# Validate cloudbaserc.json in the current directory
tcb validate
# Custom configuration file
tcb validate --config-file ./config/prod.json
# Validate a specific mode
tcb validate --mode dev
A passing run prints a resource summary and exits with 0:
[PASS] 项目校验通过
资源概览:云函数 1 个,静态托管 1 个,数据库 0 个,网关路由 2 条
Checks
| Check | Description | Example |
|---|---|---|
| Configuration structure | Matches the cloudbaserc schema, valid fields, no additional properties | gateway.routes rejects cdnType and other unknown fields |
| envId | The configuration must contain envId | — |
| Resource directories | Function directories, hosting roots, and so on exist | A missing functions/pay-common/ is reported |
| Consistency | Function or hosting referenced by a gateway target is declared | target: "function:pay-common" without that function |
Output and exit codes
| Result | Output | Exit code |
|---|---|---|
| Passed | Resource summary | 0 |
| Failed | Error list with field and fix suggestion | 1 |
错误(2)
- gateway.routes.0: 配置不符合 cloudbaserc schema:should NOT have additional properties
修复建议:请检查 gateway.routes.0 字段
- gateway.routes.1: 配置不符合 cloudbaserc schema:should NOT have additional properties
修复建议:请检查 gateway.routes.1 字段
Relation to tcb deploy
tcb deployalso guards the configuration lightly (envIdpresent, configuration valid)- Run
tcb validatebeforetcb deployin CI so problems surface early - The full check (structure / directories / consistency) is the job of
tcb validate