[Vuejs]-Swatch generator, stop function on null and undefined values

0👍

Use || instead of &&, or else it will only show the message if all errors are present. To prevent running the remaining statements, use else:

publishSwatch() {
  let value1 = this.value1;
  let value2 = this.value2;
  let name = this.value3;
  if (value1 == undefined || value2 == undefined || name == null) {
    Vue.swal('Please Enter Name and Color Values');
  } else {
    this.createSwatch();
    this.resetForm();
    this.handleSwatch();
  }
}

Leave a comment