add validator in Python