Skip to content

Instantly share code, notes, and snippets.

@mikauser001
Created March 1, 2023 16:07
Show Gist options
  • Save mikauser001/951e16d3b9858ece62374c901346ac58 to your computer and use it in GitHub Desktop.
Save mikauser001/951e16d3b9858ece62374c901346ac58 to your computer and use it in GitHub Desktop.
import textwrap
from django.core.exceptions import ValidationError
from profanity_check import predict
def check_profanity(value: str):
"""Profanity check (Programmed by a 3rd party lib)"""
if predict(textwrap.wrap(value)):
raise ValidationError(
_(
'%(value)s contains offensive parts. If this is wrong, please report it. Otherwise just refactor your content'
),
params={'value': value},
)
@mikauser001
Copy link
Author

If this is wrong, please report it, because profanity can't be accurate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment