Skip to content

Commit 9803902

Browse files
committed
Make NumberType work with masks
1 parent b22357b commit 9803902

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/components/QuestionTypes/NumberType.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
88
import TextType from './TextType.vue'
9-
import LanguageModel from '../../models/LanguageModel'
109
import { QuestionType } from '../../models/QuestionModel'
1110
1211
export default {
@@ -23,6 +22,10 @@
2322
methods: {
2423
validate() {
2524
if (this.hasValue) {
25+
if (this.question.mask) {
26+
return this.validateMask()
27+
}
28+
2629
return !isNaN(+this.dataValue)
2730
}
2831

src/components/QuestionTypes/TextType.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,18 @@
6767
methods: {
6868
validate() {
6969
if (this.question.mask && this.hasValue) {
70-
if (Array.isArray(this.question.mask)) {
71-
return this.question.mask.some(mask => mask.length === this.dataValue.length)
72-
}
73-
74-
return this.dataValue.length === this.question.mask.length
70+
return this.validateMask()
7571
}
7672
7773
return !this.question.required || this.hasValue
74+
},
75+
76+
validateMask() {
77+
if (Array.isArray(this.question.mask)) {
78+
return this.question.mask.some(mask => mask.length === this.dataValue.length)
79+
}
80+
81+
return this.dataValue.length === this.question.mask.length
7882
}
7983
}
8084
}

0 commit comments

Comments
 (0)