kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

validator doesn't work when fieldname of vue is camel style like cellPhone #289

Closed yudar1024 closed 8 years ago

yudar1024 commented 8 years ago

vue & vue-validator version

Vue.js v1.0.26, vue-validator v2.1.5

Reproduction Link

Steps to reproduce

1 new a Vue instance with data { sn:'123', name:'333', cellPhone:'5554545' } 2 add validation to input element <input type="text" class="form-control" id="cellPhone" name="cellPhone" v-model="cellPhone" v-validate:cellPhone="{ required: true}" placeholder="请输入手机号"/>

Required your cellPhone.

What is Expected?

the validatior should work correctly

What is actually happening?

the validatior dons't work.

workround: change validate:cellPhone="{ required: true}"
to validate:cellphone="{ required: true}"

it works correctly.

kazupon commented 8 years ago

You need to use the caml-case naming. see http://vuejs.github.io/vue-validator/en/syntax.html#camelcase-property