mirror of
https://github.com/supabase/supabase.git
synced 2026-06-05 12:22:26 +08:00
* Init * Initial set up for hooking up supavisor and pgbouncer * Hook up pgbouncer status check after swapping pooler type * Add check for nano compute for switching to pg bouncer * Add check for ipv4 addon * Remove expect error tag * Add badge to select options for pooler types * Remove statement mode * Resolve undefined problem with react hook form * Fix * Update UI texts from PgBouncer to Dedicated Pooler * Feex * FEEX * Fix * Small update to UI * Smol update
18 lines
734 B
TypeScript
18 lines
734 B
TypeScript
import * as z from 'zod'
|
|
|
|
export const StringNumberOrNull = z
|
|
.string()
|
|
.transform((v) => (v === '' ? null : v))
|
|
.nullable()
|
|
.refine((value) => value === null || !isNaN(Number(value)), {
|
|
message: 'Invalid number',
|
|
})
|
|
.transform((value) => (value === null ? null : Number(value)))
|
|
|
|
/**
|
|
* [Joshen] After wrangling with RHF I think this is the easiest way to handle nullable number fields
|
|
* - Declare the field normally as you would in the zod form schema (e.g field: z.number().nullable())
|
|
* - In the InputField, add a form.register call `{...form.register('field_name', { setValueAs: setValueAsNullableNumber })}`
|
|
*/
|
|
export const setValueAsNullableNumber = (v: any) => (v === '' || v === null ? null : parseInt(v))
|