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

is there any way to build custom validator with vue-loader's style? #118

Closed
zchking opened this issue Dec 30, 2015 · 3 comments
Closed

is there any way to build custom validator with vue-loader's style? #118

zchking opened this issue Dec 30, 2015 · 3 comments

Comments

@zchking
Copy link

zchking commented Dec 30, 2015

I try to use the custom validator with vue-loader structure.

I have no idea how to get this $validation-signup.username.mobile value.
Any one have the demo, and thanks very very much.:)

mobile.vue just show the key code:

<template>
    <form>
           <input class="phone_username" v-validate:username="['mobile']">                                
           <span class="text-danger" v-show="$validation-signup.username.mobile">* Need correct mobile number! </span>
   </form>
</template>

mobile.js just show the key code:

  1 import Vue from 'vue'
  2 import signup from './components/signup.vue'
  3 import VueValidator from 'vue-validator'
  4                       
  5 Vue.config.debug = true 
  6 Vue.use(VueValidator)     
  7 Vue.validator('mobile', function (val) {
  8   return /^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/.test(val)
  9 })                              
 10                                 
 11 /* eslint-disable no-new */               
 12 new Vue({                                 
 13   el: 'body',                             
 14   components: { signup }                   
 15 })
@kazupon
Copy link
Owner

kazupon commented Jan 1, 2016

You should be specified validator element directive in template of mobile.vue 😸

<template>
  <validator name="validation">
    <form>
      <input class="phone_username" v-validate:username="['mobile']">                                
      <span class="text-danger" v-show="$validation.username.mobile">* Need correct mobile number! </span>
    </form>
  </validator>
</template>

@zchking
Copy link
Author

zchking commented Jan 2, 2016

thanks,yes I have.

And the problem is that

 <validator name="validation">

the name can't use the "-" to link the word such as "signup-validation".

Is that bug or I lost some document?

@kazupon
Copy link
Owner

kazupon commented Jan 2, 2016

the name can't use the "-" to link the word such as "signup-validation".

This is the specification.

Sorry, I did not write about the name attribute detail spec.
I'm going to write the API document later.

As well as the vue.js component, the name attribute also might support the kebab-case.
Perhaps, I'll try to support it. 😸

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants