1
1
import Vue from 'vue'
2
2
import { language } from '@/i18n'
3
3
import veeValidate , { Validator } from 'vee-validate'
4
+ import stringLength from 'utf8-byte-length'
4
5
5
6
const customRules = {
6
7
singlechar : {
7
8
validate : value => {
8
- /* eslint-disable */
9
- return / ^ ( [ a - z A - Z 0 - 9 ] | [ \u4e00 - \u9fa5 ] | [ \( \) \+ \- 《 》 _ , , ; : ; “ ” ‘ ’ 。 @ # \. " ' \\ \/ \s ] ) { 0 , 256 } $ / . test ( value )
10
- /* eslint-enable */
9
+ return / ^ ( [ a - z A - Z 0 - 9 ] | [ \u4e00 - \u9fa5 ] | [ ( ) + \- 《 》 _ , , ; : ; “ ” ‘ ’ 。 @ # . " ' \\ / \s ] ) { 0 , 256 } $ / . test ( value )
10
+ }
11
+ } ,
12
+ singlecharLength : {
13
+ validate : value => {
14
+ return stringLength ( value ) <= 256
11
15
}
12
16
} ,
13
17
longchar : {
14
18
validate : value => {
15
- /* eslint-disable */
16
- return / ^ ( [ a - z A - Z 0 - 9 ] | [ \u4e00 - \u9fa5 ] | [ \( \) \+ \- 《 》 _ , , ; : ; “ ” ‘ ’ 。 @ # \. " ' \\ \/ \s ] ) { 0 , 2000 } $ / . test ( value )
17
- /* eslint-enable */
19
+ return / ^ ( [ a - z A - Z 0 - 9 ] | [ \u4e00 - \u9fa5 ] | [ ( ) + \- 《 》 _ , , ; : ; “ ” ‘ ’ 。 @ # . " ' \\ / \s ] ) { 0 , 2000 } $ / . test ( value )
20
+ }
21
+ } ,
22
+ longcharLength : {
23
+ validate : value => {
24
+ return stringLength ( value ) <= 2000
18
25
}
19
26
} ,
20
27
associationId : {
@@ -86,7 +93,9 @@ const dictionary = {
86
93
messages : {
87
94
regex : ( ) => '请输入符合自定义正则的内容' ,
88
95
longchar : ( ) => '请输入正确的长字符内容' ,
96
+ longcharLength : ( ) => '请输入2000个字符以内的内容' ,
89
97
singlechar : ( ) => '请输入正确的短字符内容' ,
98
+ singlecharLength : ( ) => '请输入256个字符以内的内容' ,
90
99
associationId : ( ) => '格式不正确,只能包含下划线,英文小写' ,
91
100
classifyName : ( ) => '请输入正确的内容' ,
92
101
classifyId : ( ) => '请输入正确的内容' ,
@@ -111,7 +120,9 @@ const dictionary = {
111
120
messages : {
112
121
regex : ( ) => 'Please enter the correct content that conform custom regex' ,
113
122
longchar : ( ) => 'Please enter the correct content' ,
123
+ longcharLength : ( ) => 'Content length max than 2000' ,
114
124
singlechar : ( ) => 'Please enter the correct content' ,
125
+ singlecharLength : ( ) => 'Content length max than 256' ,
115
126
associationId : ( ) => 'The format is incorrect and can only contain underscores and lowercase English' ,
116
127
classifyName : ( ) => 'Please enter the correct content' ,
117
128
classifyId : ( ) => 'Please enter the correct content' ,
0 commit comments