fix(address): coerce lat/lng to numbers before persist validation
Lat/lng values from the record store can arrive as strings, causing the Zod addressSchema validation to reject them on manual address edits. Use existing castAsNumberOrNull utility to ensure proper number types. Made-with: Cursor
This commit is contained in:
+3
-2
@@ -7,6 +7,7 @@ import { RecordFieldComponentInstanceContext } from '@/object-record/record-fiel
|
||||
import { FieldInputEventContext } from '@/object-record/record-field/ui/contexts/FieldInputEventContext';
|
||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||
import { useContext } from 'react';
|
||||
import { castAsNumberOrNull } from '~/utils/cast-as-number-or-null';
|
||||
|
||||
export const AddressFieldInput = () => {
|
||||
const { draftValue, setDraftValue, fieldDefinition } = useAddressField();
|
||||
@@ -25,8 +26,8 @@ export const AddressFieldInput = () => {
|
||||
addressState: newAddress?.addressState ?? null,
|
||||
addressCountry: newAddress?.addressCountry ?? null,
|
||||
addressPostcode: newAddress?.addressPostcode ?? null,
|
||||
addressLat: newAddress?.addressLat ?? null,
|
||||
addressLng: newAddress?.addressLng ?? null,
|
||||
addressLat: castAsNumberOrNull(newAddress?.addressLat),
|
||||
addressLng: castAsNumberOrNull(newAddress?.addressLng),
|
||||
};
|
||||
};
|
||||
const settings = fieldDefinition.metadata.settings;
|
||||
|
||||
Reference in New Issue
Block a user