Closed fredkingham closed 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
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)
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)