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

Commit f918e39

Browse files
committed
fix(validate): expression evaluating error
Closes #35 #103 #111
1 parent 76a8929 commit f918e39

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Validator component for Vue.js
1010

1111

1212
# Requirements
13-
- Vue.js `1.0.10`+
13+
- Vue.js `1.0.14`+
1414

1515
## NOTE
1616
vue-validator is still in its alpha verison. There may be some breaking changes.
@@ -54,10 +54,6 @@ jsdelivr
5454
# Usage
5555

5656
```javascript
57-
// NOTE: You need to set the `warnExpressionErrors` property value to `false`
58-
// See the https://github.com/vuejs/vue-validator/issues/111
59-
Vue.config.warnExpressionErrors = false
60-
6157
new Vue({
6258
el: '#app'
6359
})

src/directives/validate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { warn, attr, each } from '../util'
44
export default function (Vue) {
55

66
const _ = Vue.util
7-
const vModel = Vue.directive('model')
7+
const vIf = Vue.directive('if')
8+
Vue.compiler.terminalDirectives.push('validate')
89

910
Vue.directive('validate', {
10-
priority: vModel.priority + 1,
11+
priority: vIf.priority + 1,
1112
params: ['group', 'field'],
1213

1314
bind () {

test/specs/directives/validate.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,36 @@ describe('validate directive', () => {
3838
})
3939

4040

41+
describe('expression evaluate error', () => {
42+
// TODO: should be tested with spy library (we try to use sinon.js, however it not work ... )
43+
it('should not be called warn', (done) => {
44+
el.innerHTML =
45+
'<validator name="validator">' +
46+
'<form novalidate>' +
47+
'<input type="text" v-validate:field1="{ required: true }">' +
48+
'<p>field1 value: {{ $validator.field1.valid }}</p>' +
49+
'<div v-for="index in indexes">' +
50+
'<input type="text" :field="\'field\' + index" v-validate="{ minlength: 4 }">' +
51+
'<p>field{{index}} valid: {{ $validator[\'field\' + index].valid }}</p>' +
52+
'<span v-if="$validator[\'field\' + index].valid"> valid !!</span>' +
53+
'</div>' +
54+
'<input type="submit" v-if="$validator.valid">' +
55+
'</form>' +
56+
'</validator>'
57+
vm = new Vue({
58+
el: el,
59+
data: {
60+
indexes: [2, 3]
61+
}
62+
})
63+
vm.$nextTick(() => {
64+
assert(true)
65+
done()
66+
})
67+
})
68+
})
69+
70+
4171
describe('v-show', () => {
4272
beforeEach(() => {
4373
vm = new Vue({

0 commit comments

Comments
 (0)