POST /api/teams
{
"name": "",
"leagueId": 1
}
规则:
- 名称字段为必填项
- 联赛编号字段为必填项
- 只有联赛的所有者才能创建关联到该联赛的团队。
假设认证用户因不是联赛的所有者而无法访问联赛编号,那么是返回403响应更好(注意名称字段的规则也未满足)? 还是返回422状态码和此有效负载更好:
{
"errors": [
{
"field": "name",
"message": "Name is required."
},
{
"field": "leagueId",
"message": "User is not the owner of the league."
}
],
"message": "Validation Failed"
}