refactor: use vuelidate for vue 3
This commit is contained in:
@@ -59,6 +59,7 @@ import alertMixin from 'shared/mixins/alertMixin';
|
||||
import { mapGetters } from 'vuex';
|
||||
import validations, { getLabelTitleErrorMessage } from './validations';
|
||||
import { getRandomColor } from 'dashboard/helper/labelColor';
|
||||
import { useVuelidate } from '@vuelidate/core';
|
||||
|
||||
export default {
|
||||
mixins: [alertMixin],
|
||||
@@ -68,6 +69,9 @@ export default {
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
return { v$: useVuelidate() };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
color: '#000',
|
||||
@@ -82,7 +86,7 @@ export default {
|
||||
uiFlags: 'labels/getUIFlags',
|
||||
}),
|
||||
labelTitleErrorMessage() {
|
||||
const errorMessage = getLabelTitleErrorMessage(this.$v);
|
||||
const errorMessage = getLabelTitleErrorMessage(this.v$);
|
||||
return this.$t(errorMessage);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import validations, { getLabelTitleErrorMessage } from './validations';
|
||||
import { useVuelidate } from '@vuelidate/core';
|
||||
|
||||
export default {
|
||||
mixins: [alertMixin],
|
||||
@@ -60,6 +61,9 @@ export default {
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
return { v$: useVuelidate() };
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '',
|
||||
@@ -79,7 +83,7 @@ export default {
|
||||
}`;
|
||||
},
|
||||
labelTitleErrorMessage() {
|
||||
const errorMessage = getLabelTitleErrorMessage(this.$v);
|
||||
const errorMessage = getLabelTitleErrorMessage(this.v$);
|
||||
return this.$t(errorMessage);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user