Skip to content

feat(config): Config::validate rules — points_per_unit>0, plan→provider exists, endpoints≥1, protocol enum (+4 tests) - #72

Merged
argszero merged 1 commit into
mainfrom
feat/config-validation
Aug 17, 2026
Merged

argszero merged 1 commit into
mainfrom
feat/config-validation

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Closes #6 — config validation rules for the TOML config module (src/config.rs, landed in PR #71's P0-A).

Adds Config::validate() invoked by Config::load(), implementing the validation rules the issue requested:

  1. [points] points_per_unit > 0
  2. every plan.provider must reference an existing provider (no dangling refs)
  3. every plan has at least 1 endpoint
  4. endpoint.protocol must be one of the defined enum: openai_chat | anthropic | responses

Tests (4 new, 14 total)

  • validate_rejects_zero_points_per_unit
  • validate_rejects_missing_provider_ref
  • validate_rejects_empty_endpoints
  • validate_rejects_illegal_protocol
  • parse_config_example_ok now also asserts config.example.toml passes validation

Verification

  • cargo test — 14/14 pass
  • cargo clippy --all-targets -- -D warnings clean
  • cargo fmt --check clean
  • README status updated

Related Issue

Closes #6 (feat(config): TOML 配置加载模块 — the parse/load part was delivered in PR #71; this PR adds the 校验 rules + failure-branch tests, completing the issue's scope).

…er exists, endpoints≥1, protocol enum (+4 tests)
@argszero
argszero merged commit cca5e53 into main Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(config): TOML 配置加载模块(解析 + 校验 + 测试)

1 participant