vue-formulate icon indicating copy to clipboard operation
vue-formulate copied to clipboard

validating using regex not working for UK Postcode could be nuxt issue

Open ahmetskilinc opened this issue 2 years ago • 0 comments

Regex not working in Nuxt. I've tried to reproduce the issue but the issue isn't to do with the regex or the VueFormulate setup. I think it may be the version of Nuxt that I am using.

I'm using version 2.15.7 but in the docs it shows 2.5.1. Is Nuxt only supported above 2.5.1?

The regex is for a UK Postcode: /^(([gG][iI][rR] {0,}0[aA]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))){0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$/gi

and this is the whole FormulateInput I have:

<FormulateInput
  type="text"
  name="Postcode"
  label="Postcode (required)"
  v-model="postal"
  @keydown.space.prevent
  maxlength="7"
  minlength="5"
  :validation="[
    ['required'],
    ['max', '7', 'length'],
    ['min', '5', 'length'],
    [
      'matches',
      /^(([gG][iI][rR]{0,}0[aA]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))){0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$/gi,
    ],
  ]"
  :validation-messages="{
    required: 'Please enter a valid postcode',
    matches: 'Postcode is not valid.',
  }"
  error-behavior="blur"
/>

ahmetskilinc avatar May 20 '22 15:05 ahmetskilinc