v0.3.1 -- InstanceOf and SubclassOf
This update adds the InstanceOf and SubclassOf validators. True to their names, InstanceOf requires that a value be an instance of a base class or its subclasses, and SubclassOf requires that a value actually be a class that inherits from the specified class.
InstanceOf
# InstanceOf Example:
validations = {
"field": [InstanceOf(basestring)]
}
passes = {"field": ""} # is a <'str'>, subclass of basestring
fails = {"field": str} # is a <'type'
SubclassOf:
# SubclassOf Example
validations = {
"field": [SubclassOf(basestring)]
}
passes = {"field": str} # is a subclass of basestring
fails = {"field": int}
Thanks to @ryansb for the SubclassOf validator he submitted in #1.