admin管理员组文章数量:1384778
How can I modify my validation schema such that the entered value is boolean, either 1 or 0? not true false etc
formValue: Yup.number()
.boolean()
.typeError('boo'),
How can I modify my validation schema such that the entered value is boolean, either 1 or 0? not true false etc
formValue: Yup.number()
.boolean()
.typeError('boo'),
Share
Improve this question
asked Jun 29, 2021 at 9:52
x89x89
3,50015 gold badges79 silver badges163 bronze badges
1 Answer
Reset to default 3You can use the test
method .
formValue: Yup.number().test('is boolean',
'Please enter either 1 or 0',
(value) => value === 0 || value === 1)
Yup - test
本文标签: javascriptyup schema for boolean values (0 or 1)Stack Overflow
版权声明:本文标题:javascript - yup schema for boolean values (0 or 1) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744514022a2610048.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论