Deepwalker / trafaret

Ultimate transformation library that supports validation, contexts and aiohttp.
http://trafaret.readthedocs.org/en/latest/
BSD 2-Clause "Simplified" License
177 stars 31 forks source link

Allow "null" for Null #115

Closed Dreamsorcerer closed 4 years ago

Dreamsorcerer commented 4 years ago

Is it reasonable to allow "null" for the Null object?

Reasoning is that sometimes we're trying to operate on values passed from JS, if they've not gone through json.loads(), then we get the string value "null", rather than None. I think allowing this case, is less likely to introduce bugs in code between JS and Python.

Deepwalker commented 4 years ago

Sorry, do not think this is good idea. We can ask a lot of questions, like why "null"? What input do you expect? And how will you check for None only then? We can introduce something like StrNull that will check for some common string nulls, like null, None etc.

Dreamsorcerer commented 4 years ago

I'll rethink it, and maybe come back with ToNull/StrNull or similar. Although, in answer to checking for None only, just use Atom(None) or something direct, there's really no need for a dedicated None only object.