I don't find the option to validate a URL anymore.
What would be the best way to implement it or to add it to vee-validate 3.0?
I guess I have to extend the current vee-validate:
import { ValidationObserver, ValidationProvider, localize, extend as VeeExtend } from 'vee-validate/dist/vee-validate.full';
and then something like
const urlFixRule = (value) => {
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
'(\\#[-a-z\\d_]*)?$','i'); // fragment locator
return !!pattern.test(value);
};
VeeExtend('url', {
validate: (val) => urlFixRule(val),
message: i18n.t('custom_vee_validate.incorrect_url')
});
- Which would be the best way of validating the URL?
- Why has such a useful feature been removed?