'Hash function for using Validated objects in sets and maps.
Hash is done by hashing all keys and values and xor\'ing them together.
Returns:
Hash of validated object.'

def __hash__(self):

    result = 0
    for key in self.ATTRIBUTES.iterkeys():
        value = getattr(self, key)
        if isinstance(value, list):
            value = tuple(value)
        result = ((result ^ hash(key)) ^ hash(value))
    return result
