After doing some research, I came across a few relevant issues on Vee-validate's Github page, but unfortunately, none of them provided a complete solution to my problem. Here are the steps I took to successfully validate localhost URLs:
Install the validator package
npm install validator
Create a new rule:
const urlFixRule = (value) => {
return isURL(value, {
require_tld: false
});
};
Implement the new rule:
VeeValidate.Validator.extend('url', urlFixRule);
This is how it appears in my JavaScript 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 }
});