Commit 1056f6d3 authored by vagrant's avatar vagrant

Added the ability to specify an object as a mask

parent c387e294
...@@ -35,9 +35,8 @@ export default { ...@@ -35,9 +35,8 @@ export default {
type: String type: String
}, },
mask: { mask: {
type: String,
required: true, required: true,
validator: value => !! (value && value.length >= 1) validator: value => !! ((value && value.length >= 1) || value instanceof Object)
}, },
placeholderChar: { placeholderChar: {
type: String, type: String,
...@@ -67,6 +66,9 @@ export default { ...@@ -67,6 +66,9 @@ export default {
initMask() { initMask() {
try { try {
if (this.mask instanceof Object) {
this.mask_core = new InputMask(this.mask)
} else {
this.mask_core = new InputMask({ this.mask_core = new InputMask({
pattern: this.mask, pattern: this.mask,
value: '', value: '',
...@@ -76,7 +78,7 @@ export default { ...@@ -76,7 +78,7 @@ export default {
validate: char => /^[A-Za-zА-Яа-я]$/.test(char), validate: char => /^[A-Za-zА-Яа-я]$/.test(char),
}, },
'A': { 'A': {
validate: char => /^[A-Za-zА-Яа-я]$/.test(char) , validate: char => /^[A-Za-zА-Яа-я]$/.test(char),
transform: char => char.toUpperCase() transform: char => char.toUpperCase()
}, },
'*': { '*': {
...@@ -91,6 +93,7 @@ export default { ...@@ -91,6 +93,7 @@ export default {
}, },
} }
}) })
}
for (let i = 0; i < this.$refs.input.value.length; ++i) { for (let i = 0; i < this.$refs.input.value.length; ++i) {
this.mask_core.input(this.$refs.input.value[i]) this.mask_core.input(this.$refs.input.value[i])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment