uk-fci / nhs-number

Python package to provide utilities for NHS Numbers, including validity checks, normalisation, and generation.
https://nhs-number.uk-fci.tech/
MIT License
4 stars 6 forks source link

I _think_ 100000002 should be invalid #29

Closed fredkingham closed 1 year ago

fredkingham commented 1 year ago

So given the below... validate.is_valid(100000002) == True validate.is_valid("100000002") == False

according to all documentation I know of nhs numbers are 10 digits.

The reason the int is true is because of... https://github.com/uk-fci/nhs-number/blob/main/nhs_number/standardise.py#L44

I'm guessing the reason you're doing this is because if its entered in a number field it would have the zero stripped off the beginning. I'm not sure this is the behaviour you want.

(Feel free to close if you think this is the right behaviour)

andylaw commented 1 year ago

@fredkingham - This is the current intended behaviour, for the reason you note.

There are obviously more complicated ways that we could do this, but we figured this was the best compromise. Happy to debate alternatives if you have an urge to do so

fredkingham commented 1 year ago

my guess is you did it this way because of csv imports and some excel spreadsheet autodetecting it, thinking its a number and automatically changing to an int. ie its a spread sheet issue and should have a coerce_to_string argument in the is_valid argument (better names probably exist). I'd argue that makes it more explicit vs implicit and then you can add the warning in a comment there.

(This is definitely a style thing and feel free to close)