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

"123" 难道不是数字吗 #73

Open
zzzgit opened this issue Nov 13, 2017 · 9 comments
Open

"123" 难道不是数字吗 #73

zzzgit opened this issue Nov 13, 2017 · 9 comments

Comments

@zzzgit
Copy link

zzzgit commented Nov 13, 2017

字符串“123”就是一个数字,可是这个工具认为他不是数字
往往,我们就是需要判断一个字符串是不是合法的数字,但是这个工具直接判断他不是数字,太不科学

@zzzgit
Copy link
Author

zzzgit commented Nov 13, 2017

https://github.com/zzzgit/hakim
这个工具则认为“123”是数字

@Deathsteps
Copy link

这是个老问题了,我建议你加个transform。
{ type: 'integer', message: '必须是整数!', transform: value => +value }

@godphp
Copy link

godphp commented Apr 8, 2018

@zzzgit v-model 默认获取是字符串 你用v-model.number来绑定

@zzzgit
Copy link
Author

zzzgit commented Apr 8, 2018

@godphp 要不得,實際應用中,表單驗證的實際應用中,一個表單項可能可以輸入數字,還可以輸入特定格式的某種字符串
你用.number,就把他限定死了

@ghost
Copy link

ghost commented May 4, 2018

@Deathsteps 为什么加入transform: value => +value ,还是没用啊?

@zzzgit
Copy link
Author

zzzgit commented May 4, 2018

因為要不得

@shjszwh
Copy link

shjszwh commented Sep 27, 2018

@godphp 要不得,實際應用中,表單驗證的實際應用中,一個表單項可能可以輸入數字,還可以輸入特定格式的某種字符串
你用.number,就把他限定死了

如卿这般需求,使自定义校验而非此类格式化校验了。

@zhenujt
Copy link

zhenujt commented Jul 15, 2019

number ?

@crazyair
Copy link

react-component#2

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

6 participants