Skip to content
This repository was archived by the owner on Dec 25, 2017. It is now read-only.

Commit

Permalink
🐛 bug(validate): fix cannot change validation rule and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Jul 25, 2016
1 parent 4ac1936 commit 7013c4e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/directives/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function (Vue) {
*/

Vue.directive('validate', {
deep: true,
terminal: true,
priority: vIf.priority + PRIORITY_VALIDATE,
params: ['group', 'field', 'detect-blur', 'detect-change', 'initial', 'classes'],
Expand Down
46 changes: 46 additions & 0 deletions test/specs/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,50 @@ describe('github issues', () => {
})
})
})

describe('#284', () => {
beforeEach(done => {
el.innerHTML = `
<validator name="validation">
<input id="foo" type="text" v-model="foo" v-validate:foo="rules">
</validator>
`
vm = new Vue({
el,
data: {
foo: '',
rules: {
maxlength: {
rule: 4,
message: 'too long!!'
},
required: {
rule: true,
message: 'required!!'
}
}
}
})
vm.$nextTick(done)
})

it('should be validated', done => {
let input = el.querySelector('#foo')
vm.rules.required.message = 'required "foo" field!!'
vm.$nextTick(() => {
assert.equal(vm.$validation.foo.required, 'required "foo" field!!')
input.value = 'hello'
trigger(input, 'input')
trigger(input, 'blur')
vm.$nextTick(() => {
assert.equal(vm.$validation.foo.maxlength, 'too long!!')
vm.rules.maxlength.rule = 10
vm.$nextTick(() => {
assert(vm.$validation.foo.maxlength === false)
done()
})
})
})
})
})
})

0 comments on commit 7013c4e

Please sign in to comment.