[Vuejs]-Why the regular expression of the URL rule for the Vutify form validation with port number get error?

3👍

The problem is not related to vuetify rules or regular expressions. You should take a look to your ESLint config. This error said that your code failed “no-useless-escape” ESLint rule.

As a quick workaround, you could disable ESLint rule for some lines.
This code should work:

export default {
  data: () => ({
    valid: true,
    url: '',
    urlRules: [
      v => !!v || 'URL is required',
      v => (v && v.length <= 256) || 'URL must be less than 256 characters', /* eslint-disable-next-line no-useless-escape*/
      v => /https?:[0-9]*\/\/[\w!?/\+\-_~=;\.,*&@#$%\(\)\'\[\]]+/.test(v) || 'URL must be valid',
    ],
  }),
  components: {
  },
}

Leave a comment