Skip to content

Commit

Permalink
修改对Unicode码点大于U+FFFF的字符求长度的testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wb-yzf340490 committed Jul 12, 2018
1 parent c3bf6a6 commit ca44308
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions __tests__/string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ describe('string', () => {
new Schema({
v: {
type: 'string',
len: 3,
min: 3,
max: 3,
len: 5,
message: 'haha',
},
}).validate({
Expand All @@ -130,9 +128,7 @@ describe('string', () => {
new Schema({
v: {
type: 'string',
len: 3,
min: 3,
max: 3,
len: 8, // 原来length属性应该为8,更正之后应该为4
message: 'haha',
},
}).validate({
Expand Down
2 changes: 1 addition & 1 deletion src/rule/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function range(rule, value, source, errors, options) {
}
if (str) {
// 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".lenght !== 3
val = value.replace(spRegexp,'_').length;
val = value.replace(spRegexp, '_').length;
}
if (len) {
if (val !== rule.len) {
Expand Down

0 comments on commit ca44308

Please sign in to comment.