wotamann / vuetify-form-base

Schema-based Form Generator - Vue.js 2.0 Component based on Vuetify 2.0
https://wotamann.github.io/vuetify
232 stars 64 forks source link

`pattern` doesn't allow for regex flags #118

Closed adamenveil closed 2 years ago

adamenveil commented 2 years ago

Unable to specify a regex pattern using flags.

For instance, this is a valid regex:

let onlyLetters = /^[a-z]+$/i;
onlyLetters.test('Adam'); // true

However, this regex is not able to be supplied as a pattern in a schema:

mySchema: {
  "First Name": {
    type: 'text',
    col: 12,
    pattern: "/^[a-z]+$/i",
    validate:true,
    hint: "Only enter letters."
  }
};

I have tried it without wrapping the pattern in a string, just specifying /^[a-z]+$/i and that doesn't seem to work either.

I am able to use regex pattern strings without the / and without flags, such as pattern: "^[a-zA-Z]+$", which can achieve the same result in this scenario. But there are many times when flags would be MUCH more preferable than adding a bunch of extra modifiers into the expression.

adamenveil commented 2 years ago

Closing because I realize it's just setting the pattern attribute on a normal <input> element, and the pattern attribute is fairly limited. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern