No need for 'valid' data

Add name prop, and event emitter for changes
This commit is contained in:
Andrew Croce 2018-08-08 11:41:27 -04:00
parent 725e76dfa4
commit 6bcf7dee28

View File

@ -9,6 +9,7 @@ export default {
}, },
props: { props: {
name: String,
validation: { validation: {
type: String, type: String,
default: () => 'anything' default: () => 'anything'
@ -21,7 +22,6 @@ export default {
data: function () { data: function () {
return { return {
valid: false,
showError: false, showError: false,
showValid: false, showValid: false,
mask: inputValidations[this.validation].mask, mask: inputValidations[this.validation].mask,
@ -60,8 +60,14 @@ export default {
} else if (invalidate) { } else if (invalidate) {
this.showError = true this.showError = true
} }
this.valid = valid
this.showValid = valid this.showValid = valid
// Emit a change event
this.$emit('fieldChange', {
value,
valid,
name: this.name
})
}, },
_validate: function (value) { _validate: function (value) {