Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于一个已存在的值,需要置空,如何传参 #49

Open
gaochengyidlmu opened this issue Aug 13, 2018 · 6 comments
Open

对于一个已存在的值,需要置空,如何传参 #49

gaochengyidlmu opened this issue Aug 13, 2018 · 6 comments

Comments

@gaochengyidlmu
Copy link

gaochengyidlmu commented Aug 13, 2018

例如用户预约日期字段,用户原先选择了一个日期,保存成功。
后来用户想暂时移除该日期,于是删除了选择的日期,此时前端将该字段以 NULL 形式告知后端,该字段已被删除。
但此时 parameter 做校验时,即使标识了 required = false, allowEmpty = true,仍然会报错。

@trylovetom
Copy link

Same here
(required = false) cannt work with (allowEmpty = true)

@enjoyWeb
Copy link

enjoyWeb commented Jan 3, 2020

同问呀,前端传的字段是null,但是后端配置了type=int,required = false, allowEmpty = true,会报错呀

@fengmk2
Copy link
Member

fengmk2 commented Jan 3, 2020

能否提供一个报错的例子?

@enjoyWeb
Copy link

enjoyWeb commented Jan 3, 2020

能否提供一个报错的例子?
前端传参{sort: null},
后端eggjs在controller校验规则为sort: { type: 'int', required: false, allowEmpty: true},
报错{"message":"should be an integer","code":"invalid","field":"sort"}

@konglingwen94
Copy link

同问+1

1 similar comment
@konglingwen94
Copy link

同问+1

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

No branches or pull requests

5 participants