MCPcopy Create free account
hub / github.com/hunvreus/devpush / async_validate_username

Method async_validate_username

app/forms/user.py:41–54  ·  view source on GitHub ↗
(self, field)

Source from the content-addressed store, hash-verified

39 self.user = user
40
41 async def async_validate_username(self, field):
42 if self.db and self.user:
43 if self.user.username != field.data:
44 result = await self.db.execute(
45 select(User).where(
46 func.lower(User.username) == field.data.lower(),
47 User.status != "deleted",
48 User.id != self.user.id,
49 )
50 )
51 if result.scalar_one_or_none():
52 raise ValidationError(
53 _("A user with this username already exists.")
54 )
55
56 def validate_avatar(self, field):
57 if field.data:

Callers

nothing calls this directly

Calls 1

_Function · 0.50

Tested by

no test coverage detected