UK postcodes are quite sophisticated though, and I have seen regexes around that do sort out which numbers are allowed with which letters combinations. (for example the letter "O" will never appear, it would be too easy to confuse it with a zero).
It ought to be possible to at least identify that the first letter (or two depending on the town) is valid, and then go on to run the regex.
See the wikipedia page on UK postcodes for a fuller run down if you do want to better understand them.
a) check first letter (or two), on false, fail
b) run a (more expensive in cycles) regex pattern match, on false, fail
c) cURL out to a lookup
Taking your example "zz123 456" zz is clearly not one of the recognised prefixes, so abort.
But even if it were "GU12 123" one of the aforementioned established regexes would then fail it, so abort.
If this still permits enough bad postcodes to be a problem, then consider going out to the apis.
UK postcode regex - google results