Prohibit profanity in usernames

Hey there!

I have the following check for specific characters which we allow in our usernames:

var regex = /^[a-zA-Z0-9-_]+$/;
 return regex.test(p1);

Does anyone know how I can implement a check for profanity? At the moment we just create users with the profane usernames and it blocks the username from being used because it’s already in use, but that’s using up our user table, and it isn’t very intuitive for the user to see that it’s just “in use” when changing their username.

This is what we currently do:


The user tries to set the username to a blocked word, but sees it’s already taken and the app doesn’t allow them to change it.
image
The user “Profanity” with the username “@profanity

Thanks!

Rather than creating a user row for each name you don’t want, I think it would be better to create a comma delimited list of profane words and any variations. Then turn that list into an array using a Split Text column. Then you can check if the entered username is included in that list and/or the list is included in the username.

3 Likes

As an alternative, you can use AI.

1 Like

How exactly would I be able to use AI? Does Glide AI have something like that?

Robert Petito once demonstrated in his video the use of open AI in a Build AI chat. I haven’t tried Glide’s native AI for profanity.

You can see it around the 25 minute mark

3 Likes

This is what seemed to work best for me! Now, once an user tries to change their name to anything profane, vulgar, homophobic, transphobic, racist, sexist or other inappropriate things, my app will error out and won’t let the user change their username.

This is the prompt I used:

Does this username contain any vulgarity or profanity, or does it have any homophobic, transphobic, racist, sexist or other innapropriate connotations? Things like “I’m gay” or “lesbian lover” shouldn’t count.

Thanks a lot! :blush:

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.