我发送有效的补丁请求来更新用户个人资料。我制定了规则,要求使用名字和姓氏,生日是描述无垃圾邮件的日期,性别在提供的性别列表中。它在检查名字时立即失败,但我检查了请求,所有信息都在那里。我希望有人能帮我看看我做错了什么。
Axios补丁请求
axios.patch(
`/api/users/${this.user.user_name}/profile/edit`, {
firstName : this.firstNameEdit,
lastName : this.lastNameEdit,
birthday : this.birthdayEdit,
gender : this.genderEdit,
hometown : this.hometownEdit,
currentCity : this.currentCityEdit,
description : this.descriptionEdit,
})
请求类中的Laravel规则:
public function rules()
{
return [
'firstName' => 'required',
'lastName' => 'required',
'birthday' => 'date',
'description' => new SpamFree(),
'gender' => Rule::in(['male', 'female', 'other'])
];
}
例外:
The given data was invalid. Status 422.