Last active
November 8, 2020 01:44
-
-
Save walison17/39dac4418904359e5405b557a5596a7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UniqueDocumentValidator: | |
def __init__(self, message='Já existe um cadastro com esse documento, verifique e tente novamente'): | |
self.message = message | |
def __call__(self, value): | |
if User.objects.filter(doc=value).exists(): | |
raise ValidationError(self.message, code='unique_document', params={'value': value}) | |
return value | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment