text: // const Validator = require('validator');
  // const isEmpty = require('is-empty');
  
  import Validator from 'validator';
  import isEmpty from 'is-empty';
  
  export default function validateRegisterInput(data) {
      let errors = {};
  
      // Convert empty filelds to an empty string
      // so we can use validator function
      data.name = !isEmpty(data.name) ? data.name : "";
      data.email = !isEmpty(data.email) ? data.email : "";
      data.password = !isEmpty(data.password) ? data.password : "";
      data.confirmPassword = !isEmpty(data.confirmPassword) ? data.confirmPassword : "";
  
      console.log(data.name);
      // Name Check 
      if(Validator.isEmpty(data.name)) {
          errors.name = "Name field is required ";
      }
  
      // Email Check 
      if(Validator.isEmpty(data.email)) {
          errors.email = "Email field is required";
      } else if (!Validator.isEmail(data.email)) {
          errors.email = "Email is invalid";
      }
  
      // Password checks 
      if(Validator.isEmpty(data.password)) {
          errors.password = "Password field is required";
      }
  
      if(Validator.isEmpty(data.confirmPassword)) {
          errors.password = "Confirm password field is required";
      }
  
      if(!Validator.isLength(data.password, {min: 6, max: 30})) {
          errors.password = "Password must be at least 6 characters";
      }
  
      if(!Validator.equals(data.password, data.confirmPassword)) {
          errors.confirmPassword = "Passwords must match";
      }
  
      return {
          errors,
          isValid: isEmpty(errors)
      };
  };
  