diff --git a/src/Formulario.ts b/src/Formulario.ts index c4879f5..90f046e 100644 --- a/src/Formulario.ts +++ b/src/Formulario.ts @@ -1,8 +1,8 @@ import { VueConstructor } from 'vue' -import rules from '@/validation/rules' -import messages from '@/validation/messages' import merge from '@/utils/merge' +import validationRules from '@/validation/rules' +import validationMessages from '@/validation/messages' import FormularioForm from '@/FormularioForm.vue' import FormularioGrouping from '@/FormularioGrouping.vue' @@ -15,8 +15,8 @@ import { } from '@/validation/validator' interface FormularioOptions { - rules?: any; - messages?: Record; + validationRules?: any; + validationMessages?: Record; } // noinspection JSUnusedGlobalSymbols @@ -24,12 +24,12 @@ interface FormularioOptions { * The base formulario library. */ export default class Formulario { - public rules: Record = {} - public messages: Record = {} + public validationRules: Record = {} + public validationMessages: Record = {} constructor () { - this.rules = rules - this.messages = messages + this.validationRules = validationRules + this.validationMessages = validationMessages } /** @@ -49,8 +49,8 @@ export default class Formulario { */ extend (extendWith: FormularioOptions): Formulario { if (typeof extendWith === 'object') { - this.rules = merge(this.rules, extendWith.rules || {}) - this.messages = merge(this.messages, extendWith.messages || {}) + this.validationRules = merge(this.validationRules, extendWith.validationRules || {}) + this.validationMessages = merge(this.validationMessages, extendWith.validationMessages || {}) return this } throw new Error(`[Formulario]: Formulario.extend() should be passed an object (was ${typeof extendWith})`) @@ -60,14 +60,14 @@ export default class Formulario { * Get validation rules by merging any passed in with global rules. */ getRules (extendWith: Record = {}): Record { - return merge(this.rules, extendWith) + return merge(this.validationRules, extendWith) } /** * Get validation messages by merging any passed in with global messages. */ getMessages (vm: Vue, extendWith: Record): Record { - const raw = merge(this.messages || {}, extendWith) + const raw = merge(this.validationMessages || {}, extendWith) const messages: Record = {} for (const name in raw) { diff --git a/test/unit/FormularioForm.test.js b/test/unit/FormularioForm.test.js index 8d1327d..78d5cc5 100644 --- a/test/unit/FormularioForm.test.js +++ b/test/unit/FormularioForm.test.js @@ -5,7 +5,7 @@ import Formulario from '@/index.ts' import FormularioForm from '@/FormularioForm.vue' Vue.use(Formulario, { - messages: { + validationMessages: { required: () => 'required', 'in': () => 'in', min: () => 'min', diff --git a/test/unit/FormularioInput.test.js b/test/unit/FormularioInput.test.js index 9475ad3..9f732fc 100644 --- a/test/unit/FormularioInput.test.js +++ b/test/unit/FormularioInput.test.js @@ -9,13 +9,13 @@ import FormularioInput from '@/FormularioInput.vue' const globalRule = jest.fn(() => { return false }) Vue.use(Formulario, { - rules: { globalRule }, - messages: { + validationRules: { globalRule }, + validationMessages: { required: () => 'required', 'in': () => 'in', min: () => 'min', globalRule: () => 'globalRule', - } + }, }) describe('FormularioInput', () => {