I am currently updating an input validation library from a year ago, and while reviewing the IsEmpty() validator, I noticed that it was seeing strings with only spaces as NOT EMPTY, like so:
s = ' '
This is of course normal, as Python sees strings with spaces as containing value as opposed to a truly empty string that would evaluate to None.
My question is, can anyone think of a reason why I should not make a string with spaces evaluate to EMPTY for the purposes of my validation library?
Thoughts appreciated.
EDIT: I am updating this to clarify that this question was NOT INTENDED to cover a domain specific application. This library is open source and I am updating for the benefit of the community. Therefore, this question was more of a survey to hear out suggestions on how to implement this (in the manner of a library) to best serve Python developers and their validation needs. I have opted to include 2 methods to provide flexibility to consuming programs.
This is a domain-dependant question – it depends on each application.
I would suggest having two functions, one which defaults one way, and the other which defaults the other, and each having a keyword argument to select the other behaviour.