@@ -39,9 +39,8 @@ export default {
39
39
type : String ,
40
40
} ,
41
41
mask : {
42
- type : String ,
43
42
required : true ,
44
- validator : value => ! ! ( value && value . length >= 1 ) ,
43
+ validator : value => ! ! ( ( value && value . length >= 1 ) || value instanceof Object )
45
44
} ,
46
45
placeholderChar : {
47
46
type : String ,
@@ -70,32 +69,36 @@ export default {
70
69
methods : {
71
70
initMask ( ) {
72
71
try {
73
- this . maskCore = new InputMask ( {
74
- pattern : this . mask ,
75
- value : '' ,
76
- placeholderChar : this . placeholderChar ,
77
- /* eslint-disable quote-props */
78
- formatCharacters : {
79
- 'a' : {
80
- validate : char => / ^ [ A - Z a - z А - Я а - я ] $ / . test ( char ) ,
81
- } ,
82
- 'A' : {
83
- validate : char => / ^ [ A - Z a - z А - Я а - я ] $ / . test ( char ) ,
84
- transform : char => char . toUpperCase ( ) ,
85
- } ,
86
- '*' : {
87
- validate : char => / ^ [ \d A - Z a - z А - Я а - я ] $ / . test ( char ) ,
88
- } ,
89
- '#' : {
90
- validate : char => / ^ [ \d A - Z a - z А - Я а - я ] $ / . test ( char ) ,
91
- transform : char => char . toUpperCase ( ) ,
92
- } ,
93
- '+' : {
94
- validate : ( ) => true ,
72
+ if ( this . mask instanceof Object ) {
73
+ this . maskСore = new InputMask ( this . mask )
74
+ } else {
75
+ this . maskCore = new InputMask ( {
76
+ pattern : this . mask ,
77
+ value : '' ,
78
+ placeholderChar : this . placeholderChar ,
79
+ /* eslint-disable quote-props */
80
+ formatCharacters : {
81
+ 'a' : {
82
+ validate : char => / ^ [ A - Z a - z А - Я а - я ] $ / . test ( char ) ,
83
+ } ,
84
+ 'A' : {
85
+ validate : char => / ^ [ A - Z a - z А - Я а - я ] $ / . test ( char ) ,
86
+ transform : char => char . toUpperCase ( ) ,
87
+ } ,
88
+ '*' : {
89
+ validate : char => / ^ [ \d A - Z a - z А - Я а - я ] $ / . test ( char ) ,
90
+ } ,
91
+ '#' : {
92
+ validate : char => / ^ [ \d A - Z a - z А - Я а - я ] $ / . test ( char ) ,
93
+ transform : char => char . toUpperCase ( ) ,
94
+ } ,
95
+ '+' : {
96
+ validate : ( ) => true ,
97
+ } ,
95
98
} ,
96
- } ,
97
- /* eslint-enable */
98
- } ) ;
99
+ /* eslint-enable */
100
+ } ) ;
101
+ }
99
102
[ ...this . $refs . input . value ] . reduce ( ( memo , item ) => this . maskCore . input ( item ) , null ) ;
100
103
this . maskCore . setSelection ( {
101
104
start : 0 ,
0 commit comments