kazupon / vue-validator

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

Bug in required when required value != true #231

Closed tremendus closed 8 years ago

tremendus commented 8 years ago

Issue: When passing any value to required validator, vue-validator always interprets the required as required, even when value of required passed to the validator is false.

Expected When toggling required true/false, expect the behaviour of the validator to reflect state of boolean

eg:

// jade/pug template
.form-group(v-validate-class)
  label.control-label Depends on {{ isRequired }} // false
  input.form-control(type="text", v-validate:zip="{ required: isRequired }")

// vue isRequired computed property
computed: {
  isRequired () {
    return false
  }
}

The result is that the field is still required. Even after removing the computed property as setting it manually:

.form-group(v-validate-class)
  label.control-label Depends on {{ isRequired }} // false
  input.form-control(type="text", v-validate:zip="{ required: false }")

... the field is still required

kazupon commented 8 years ago

ref #217

The required validate whether is input field of form. The required is not toggle of validation.