Closed davecarlson closed 1 year ago
Hi there
Here's the interface: https://github.com/ideal-postcodes/postcode/blob/master/lib/index.ts#L285
It only accepts a string. If you're not sure about what types are flowing through your application you can parse(user.postcode || "")
- will have the effect of producing invalid postcode for null
Hi cblanc, yes I saw the interface and your suggestion is what i'm actually doing anyway, though I raised the issue as it's less obvious if someone was using it in JS rather than typescript.
I did notice that the interface for the parser itself underneath actually accepts string or null: https://github.com/ideal-postcodes/postcode/blob/b67442dfb369fca91e6c853823dcc76542bceac0/lib/index.ts#L46
usage:
I would expect if the parse function is passed null, it would return isValid: false instead: