# pydantic.errors.ConfigError: 字段验证器必须返回值

- **ID:** `python/pydantic-field-validator-missing-return`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在 Pydantic v2 中，@field_validator 装饰的函数必须返回值；如果返回 None 或不返回，Pydantic 会因验证链断裂而抛出 ConfigError。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 2.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   Ensure validator returns the value: @field_validator('field') def validate_field(cls, v): return v
   ```
2. **** (90% 成功率)
   ```
   Use mode='before' and still return the value, e.g., return v.strip()
   ```

## 无效尝试

- **** — Pydantic expects a value to continue processing; None causes ConfigError. (90% 失败率)
- **** — Raising exceptions is fine, but if no exception and no return, it fails. (60% 失败率)
