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

Commit

Permalink
fix(validate): expression evaluating error
Browse files Browse the repository at this point in the history
Closes #35 #103 #111
  • Loading branch information
kazupon committed Jan 16, 2016
1 parent 76a8929 commit f918e39
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Validator component for Vue.js


# Requirements
- Vue.js `1.0.10`+
- Vue.js `1.0.14`+

## NOTE
vue-validator is still in its alpha verison. There may be some breaking changes.
Expand Down Expand Up @@ -54,10 +54,6 @@ jsdelivr
# Usage

```javascript
// NOTE: You need to set the `warnExpressionErrors` property value to `false`
// See the https://github.com/vuejs/vue-validator/issues/111
Vue.config.warnExpressionErrors = false

new Vue({
el: '#app'
})
Expand Down
5 changes: 3 additions & 2 deletions src/directives/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { warn, attr, each } from '../util'
export default function (Vue) {

const _ = Vue.util
const vModel = Vue.directive('model')
const vIf = Vue.directive('if')
Vue.compiler.terminalDirectives.push('validate')

Vue.directive('validate', {
priority: vModel.priority + 1,
priority: vIf.priority + 1,
params: ['group', 'field'],

bind () {
Expand Down
30 changes: 30 additions & 0 deletions test/specs/directives/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ describe('validate directive', () => {
})


describe('expression evaluate error', () => {
// TODO: should be tested with spy library (we try to use sinon.js, however it not work ... )
it('should not be called warn', (done) => {
el.innerHTML =
'<validator name="validator">' +
'<form novalidate>' +
'<input type="text" v-validate:field1="{ required: true }">' +
'<p>field1 value: {{ $validator.field1.valid }}</p>' +
'<div v-for="index in indexes">' +
'<input type="text" :field="\'field\' + index" v-validate="{ minlength: 4 }">' +
'<p>field{{index}} valid: {{ $validator[\'field\' + index].valid }}</p>' +
'<span v-if="$validator[\'field\' + index].valid"> valid !!</span>' +
'</div>' +
'<input type="submit" v-if="$validator.valid">' +
'</form>' +
'</validator>'
vm = new Vue({
el: el,
data: {
indexes: [2, 3]
}
})
vm.$nextTick(() => {
assert(true)
done()
})
})
})


describe('v-show', () => {
beforeEach(() => {
vm = new Vue({
Expand Down

0 comments on commit f918e39

Please sign in to comment.