-
Notifications
You must be signed in to change notification settings - Fork 91
Multiple choice validator #12
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
Open
chrisyip
wants to merge
10
commits into
sofish:master
Choose a base branch
from
chrisyip:multiple-choice-validator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3110d3a
Merge branch 'master' of https://github.com/sofish/validator.js
chrisyip ed9c5a9
Merge branch 'master' of https://github.com/sofish/validator.js
chrisyip 57bce4f
Merge commit '4420b8da3a22f5cf25097f66bc85041b94d86295'
chrisyip b9b21cc
more reliable text validator.
chrisyip 879824d
Merge commit '7497f6777c8fc207e67c854bb5570da7823c0b7d'
chrisyip ef6fa51
Merge commit '9f683197b2470a59ed75b17f350399b3185ef70f'
chrisyip e60939e
support multiple-choice validation
chrisyip 99cebaa
Merge branch 'master' of https://github.com/sofish/validator.js into …
chrisyip bdf3f8a
refactor code.
chrisyip b05d6ab
Merge branch 'master' of https://github.com/sofish/validator.js into …
chrisyip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会不会
data-group=3-1,data-group=3-2,data-group=3-3比较好?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是用作分组,我也考虑过用
data-group,只是3-1这样区分每一个元素可能没什么必要,因为需要额外处理。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看这个实现:
validator.js/validator.js
Line 159 in ec7d36b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3-1看上去虽然比更适合,但是操作难度更大,以社交类表单的兴趣调查为例,假设已有 12 个选择项,12-N,如果这时候增删选项,意味着所有 HTML 都可能需要改,如果需要改动顺序,那更容易改错。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑一下循环输出,代码总有办法 dry,而且,1,4 这种也需要把所有项变成 1,3 如果删除一项的话;另外,从语义上看,3-1 这种更好理解。大家都知道是3个中的第1个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1,4这种其实会忽略掉后面的,只取第一个的值,至于用,是从正则那借过来,因为这货和3-1的区别在于,它只是一个区间。3-1、3-2和3-3只能告诉别人「有多少个」、「这是第几个」,但1,4的意思则是「至少 1 个,最多 4 个」。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3-1、3-2这种方法用在 group 上我没意见,但是用在 limits 上就不适合,如果只是用-代替,那也可以,但也是用在data-limits上,而不是data-group。