feat: enhance domain validation by trimming whitespace from host input

- Updated the domain validation schema to ensure the host string does not have leading or trailing spaces.
- Added a refinement to the host field to validate and transform the input accordingly.
- Adjusted the create and update domain functions to trim the host value before saving to the database.
This commit is contained in:
Mauricio Siu
2025-11-30 12:41:42 -06:00
parent b1505651c2
commit fe7a73baee
4 changed files with 37 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ export const createDomain = async (input: typeof apiCreateDomain._type) => {
.insert(domains)
.values({
...input,
host: input.host?.trim(),
})
.returning()
.then((response) => response[0]);
@@ -120,6 +121,7 @@ export const updateDomainById = async (
.update(domains)
.set({
...domainData,
...(domainData.host && { host: domainData.host.trim() }),
})
.where(eq(domains.domainId, domainId))
.returning();