semisleep / simple-vue-validator

A simple yet flexible validator library for vue.js
MIT License
293 stars 28 forks source link

"Error: Validator.value not set" when passing undefined #49

Closed dasDaniel closed 6 years ago

dasDaniel commented 6 years ago

I've got a select input that triggers conditional validations. The first item is intentionally left blank and passes a value of undefined to the validator

this generates an error:

    'formData.country': function (value) {
      return Validator.value(value).required();
    },

this does not, because the value passed cannot be null or undefined (or 0 or false in this case)

    'formData.country': function (value) {
      return Validator.value(value || '').required();
    },

It would be helpful, I think,to have the possibility of passing an undefined or null handled internally.

dasDaniel commented 6 years ago

in retrospect, passing undefined is a bad idea.