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

Commit

Permalink
feat(reset): change meta method name
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `$validatorReset` to `$resetValidation`
  • Loading branch information
kazupon committed Feb 22, 2016
1 parent 6678a53 commit f4fcd64
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ setTimeout(function () {

# Reset validation results

You can reset the validation results with `$validatorReset()` Vue instance meta method that defined with validator dynamically. the below the exmpale:
You can reset the validation results with `$resetValidation()` Vue instance meta method that defined with validator dynamically. the below the exmpale:

```html
<div id="app">
Expand All @@ -391,7 +391,7 @@ You can reset the validation results with `$validatorReset()` Vue instance meta
<p v-if="$validation1.comment.maxlength">Your comment is too long.</p>
</div>
<input type="submit" value="send" v-if="$validation1.valid">
<button type="button" @click="onReset">Validation Reset</button>
<button type="button" @click="onReset">Reset Validation</button>
</form>
<pre>{{ $validation1 | json }}</pre>
</validator>
Expand All @@ -403,7 +403,7 @@ new Vue({
el: '#app',
methods: {
onReset: function () {
this.$validatorReset()
this.$resetValidation()
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions example/reset/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>validation result reset example</title>
<title>validation result resetting example</title>
<script src="../../node_modules/vue/dist/vue.min.js"></script>
<script src="../../dist/vue-validator.min.js"></script>
<style>
Expand All @@ -26,7 +26,7 @@
<p v-if="$validation1.comment.maxlength">Your comment is too long.</p>
</div>
<input type="submit" value="send" v-if="$validation1.valid">
<button type="button" @click="onReset">Validation Reset</button>
<button type="button" @click="onReset">Reset Validation</button>
</form>
<pre>{{ $validation1 | json }}</pre>
</validator>
Expand All @@ -36,7 +36,7 @@
el: '#app',
methods: {
onReset: function () {
this.$validatorReset()
this.$resetValidation()
}
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default class Validator {
util.Vue.util.defineReactive(this._dir.vm, this.name, this._scope)
this._dir.vm._validatorMaps[this.name] = this

// define the validation reset meta method to vue instance
this._dir.vm.$validatorReset = () => {
// define the validation resetting meta method to vue instance
this._dir.vm.$resetValidation = () => {
this.resetValidation()
}

Expand Down
8 changes: 4 additions & 4 deletions test/specs/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('reset', () => {
trigger(field2, 'input')
trigger(field2, 'blur')
vm.$nextTick(() => {
vm.$validatorReset()
vm.$resetValidation()

assert(vm.$validator1.field1.required === false)
assert(vm.$validator1.field1.min === false)
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('reset', () => {
trigger(checkbox2, 'change')
trigger(checkbox2, 'blur')
vm.$nextTick(() => {
vm.$validatorReset()
vm.$resetValidation()

assert(vm.$validator1.field1.required === false)
assert(vm.$validator1.field1.minlength === false)
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('reset', () => {
trigger(radio3, 'change')
trigger(radio3, 'blur')
vm.$nextTick(() => {
vm.$validatorReset()
vm.$resetValidation()

assert(vm.$validator1.field1.required === false)
assert(vm.$validator1.field1.valid === true)
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('reset', () => {
trigger(select, 'change')
trigger(select, 'blur')
vm.$nextTick(() => {
vm.$validatorReset()
vm.$resetValidation()

assert(vm.$validator1.lang.required === false)
assert(vm.$validator1.lang.minlength === false)
Expand Down

0 comments on commit f4fcd64

Please sign in to comment.