Fix input validations

This commit is contained in:
Andrew Croce
2018-08-10 08:58:31 -04:00
parent 1b2e091a69
commit db1dd062ee
2 changed files with 29 additions and 22 deletions

View File

@@ -14,27 +14,37 @@ export default {
type: String,
default: () => 'anything'
},
setValue: {
initialValue: {
type: String,
default: () => ''
}
},
initialErrors: Array
},
data: function () {
return {
showError: false,
showError: (this.initialErrors && this.initialErrors.length) || false,
showValid: false,
mask: inputValidations[this.validation].mask,
pipe: inputValidations[this.validation].pipe || undefined,
keepCharPositions: inputValidations[this.validation].keepCharPositions || false,
value: this.setValue
value: this.initialValue
}
},
computed:{
rawValue: function () {
return this._rawValue(this.value)
}
},
mounted: function () {
if (this.value && this.mask) {
if (this.value) {
this._checkIfValid({ value: this.value, invalidate: true })
this.value = conformToMask(this.value, this.mask).conformedValue
if (this.mask) {
this.value = conformToMask(this.value, this.mask).conformedValue
}
}
},