text: const Validator = require('validator')
  const isEmpty = require('./isEmpty')
  
  module.exports = function validateChangeInput (data) {
    let errors = {}
  
    data.password = !isEmpty(data.password) ? data.password : ''
    data.confirmPassword = !isEmpty(data.confirmPassword)
      ? data.confirmPassword
      : ''
  
    if (Validator.isEmpty(data.password)) {
      errors.password = 'Password is required'
    }
  
    if (!Validator.isLength(data.password, { min: 6, max: 30 })) {
      errors.password = 'Password must be more than 5 characters'
    }
  
    if (Validator.isEmpty(data.confirmPassword)) {
      errors.confirmPassword = 'Please confirm password'
    }
  
    if (!Validator.equals(data.password, data.confirmPassword)) {
      errors.confirmPassword = 'Password must match'
    }
  
    return {
      errors,
      isValid: isEmpty(errors)
    }
  }
  