Forum Documentation Showcase Pricing Learn more

UK Postcode Regex Validation

Hello Bubblers,

Similar to:

I have an input:

The work flow is setup.

I would like to be able to utilise the regex from the above linked forum post to actually check whether the input conforms to the postcode structure and allow the workflow to continue. If it doesn’t, I will display to the user “Postcode is an invalid format”.

How would I actually go about achieving this? I tried “when inputs value extract with regex” but got as far as that as I don’t know what to do and have never used regex!

Finally, if there is a better way and someone has implemented it, I’m all ears!

Cheers,

Dan

i would suggest making an api call to validate… such as https://postcodes.io/

2 Likes

Bubble does not handle regex “groups” very well.

That is, where the output from the regex is an array (so the parts of the postcode) it is rather hard to work out what has been returned.

What you may need to do is count the output from a matching regex. If it is zero then no matching groups have been found, so it is invalid.

1 Like

Thank you both @Bubbleboy and @NigelG.

I like the look of Postcodes.io so will pass the input to that, if status 200 then proceed.

How I do that is a head scratcher. Ive used API’s like Geocode to get address data but in terms of validating data without a particular API plugin, I’m in the dark.

Cheers.

just makea GET to http://api.postcodes.io/postcodes/postcode

Try it in a browser …you’ll get the json response

one i made earlier…apt with all thats going on at No10

http://api.postcodes.io/postcodes/SW1A%202AA

Thanks @Bubbleboy.

Just had to do a crash course in APIs with Bubble. Had no idea about the API Connector, brilliant.

Was able to setup the GET URL and use the Validate option on Postcodes.io API to return a body status of true or false.

Cheers.

Hello. I also had a problem with registration, but I am from the UK. so it turned out I needed my postcode, I had to look for it because I did not know it and no one in my environment neither did, so I started to google and found a perfect site, there you can find more about postcodes by any address or on the map.