After searching, I found some related issues on Vee-validate's Github, but none solved my problem completely. Here's what I had to do to get it to validate localhost URLs:
Add the validator package
npm install validator
Add a new rule:
const urlFixRule = (value) => {
return isURL(value, {
require_tld: false
});
};
Apply the new rule:
VeeValidate.Validator.extend('url', urlFixRule);
How it looks in my js file
import Vue from 'vue';
import isURL from 'validator/lib/isURL';
import VeeValidate from 'vee-validate';
import App from './App';
// Form Validation (https://github.com/baianat/vee-validate)
Vue.use(VeeValidate);
// Temporary Fix for Vee-validate bug, until the next release
const urlFixRule = (value) => {
return isURL(value, {
require_tld: false
});
};
VeeValidate.Validator.extend('url', urlFixRule);
/* eslint-disable no-new */
new Vue({
el: '#app',
template: '<App/>',
components: { App }
});