alecthomas/voluptuous — pull request #77 by xsleonard (2014-06-22 20:57:30+00:00)
Title: Boolean schema, Is validator

I was thinking it would be a breaking change but that's because I thought `bool` would be treated as a callable in `_compile_scalar` as well, but its handle by `type` at that point.

I've added an `Is` validator for doing `x is y`, since my original intention was this behavior for boolean literals.

Turns out using `False` or `True` as a schema value will do the same as `IsFalse` and `IsTrue`. Maybe there was a forgotten reason for not allowing the bool literals as schema values? `Is`, `IsFalse` and `IsTrue` cover all cases here; `bool` does not need to be added to the `isinstance` check if its a problem.

One reason I can think of is that requiring a special validator rather than the literal makes it more clear that e.g. `0` is valid for `False`. While the user should know that `0 == False`, they could make the wrong assumption and think that voluptuous is doing an `is` for that.

This leaves us with `Is(False)` and `IsFalse` behaving differently. Maybe a rename of `IsFalse` if you get to an API breaking version.