| 332 | ] |
| 333 | |
| 334 | async def async_validate_hostname(self, field): |
| 335 | if field.data: |
| 336 | query = select(Domain).where( |
| 337 | func.lower(Domain.hostname) == field.data.lower() |
| 338 | ) |
| 339 | if self.domain_id.data: |
| 340 | query = query.where(Domain.id != int(self.domain_id.data)) |
| 341 | result = await self.db.execute(query) |
| 342 | domain = result.scalar_one_or_none() |
| 343 | if domain: |
| 344 | raise ValidationError(_("This domain is already in use.")) |
| 345 | |
| 346 | def validate_environment_id(self, field): |
| 347 | if self.type.data == "route" and not field.data: |