feat(trucks): site_id column and site/truck helpers
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
|
||||
export type SiteIdInput = { ok: true; value: string | null | undefined } | { ok: false }
|
||||
|
||||
// undefined = field not sent, null/'' = clear the link, uuid string = set it.
|
||||
export function parseSiteId(raw: unknown): SiteIdInput {
|
||||
if (raw === undefined) return { ok: true, value: undefined }
|
||||
if (raw === null || raw === '') return { ok: true, value: null }
|
||||
if (typeof raw === 'string' && UUID_RE.test(raw)) return { ok: true, value: raw }
|
||||
return { ok: false }
|
||||
}
|
||||
Reference in New Issue
Block a user