kazupon / vue-validator

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

Not possible to use validation groups with radio inputs #234

Closed priithansen closed 8 years ago

priithansen commented 8 years ago

vue & vue-validator version

1.0.24, 2.1.1

Reproduction Link

https://jsfiddle.net/gfd06j7o/

Steps to reproduce

1 - Add group="group1" to one or both radio inputs in the jsfiddler.

What is Expected?

Possible to validate radio inputs based on groups like described in docs http://vuejs.github.io/vue-validator/en/grouping.html for regular inputs

What is actually happening?

vue-validator.js:1912 - Uncaught TypeError: Cannot read property 'validation' of undefined

which is the "var validation =" line in the following code snippet

  Validator.prototype.addGroupValidation = function addGroupValidation(group, field) {
      var indexOf = exports$1.Vue.util.indexOf;

      var validation = this._validations[field] || this._checkboxValidations[field].validation || this._radioValidations[field].validation;
      var validations = this._groupValidations[group];

      validations && ! ~indexOf(validations, validation) && validations.push(validation);
    };
priithansen commented 8 years ago

Awesome!