Fix ADDRESS field persist error when lat/lng values are strings
The addressLat and addressLng fields use the NUMERIC type (BigFloat scalar), which can arrive as strings in some data paths. The Zod validation schema in isFieldAddressValue only accepted numbers, causing the persist operation to throw "Invalid value to persist" for ADDRESS type fields. Updated the schema and types to accept both string and number values for addressLat and addressLng. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
66deb8be63
commit
d6c53b40bb
+2
-2
@@ -55,8 +55,8 @@ export type FieldAddressDraftValue = {
|
||||
addressState: string | null;
|
||||
addressPostcode: string | null;
|
||||
addressCountry: string | null;
|
||||
addressLat: number | null;
|
||||
addressLng: number | null;
|
||||
addressLat: number | string | null;
|
||||
addressLng: number | string | null;
|
||||
};
|
||||
export type FieldJsonDraftValue = string;
|
||||
export type FieldActorDraftValue = {
|
||||
|
||||
+2
-2
@@ -267,8 +267,8 @@ export type FieldAddressValue = {
|
||||
addressState: string | null;
|
||||
addressPostcode: string | null;
|
||||
addressCountry: string | null;
|
||||
addressLat: number | null;
|
||||
addressLng: number | null;
|
||||
addressLat: number | string | null;
|
||||
addressLng: number | string | null;
|
||||
};
|
||||
export type FieldSelectValue = string | null;
|
||||
export type FieldMultiSelectValue = string[] | null;
|
||||
|
||||
+15
@@ -34,6 +34,21 @@ describe('isFieldAddressValue', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for address values with string lat/lng', () => {
|
||||
expect(
|
||||
isFieldAddressValue({
|
||||
addressStreet1: '',
|
||||
addressStreet2: '',
|
||||
addressCity: '',
|
||||
addressState: '',
|
||||
addressPostcode: '',
|
||||
addressCountry: 'Türkiye',
|
||||
addressLat: '38.963745',
|
||||
addressLng: '35.243322',
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for incomplete address', () => {
|
||||
expect(isFieldAddressValue({ addressStreet1: '123 Main St' })).toBe(false);
|
||||
});
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ export const addressSchema = z.object({
|
||||
addressState: z.string().nullable(),
|
||||
addressPostcode: z.string().nullable(),
|
||||
addressCountry: z.string().nullable(),
|
||||
addressLat: z.number().nullable(),
|
||||
addressLng: z.number().nullable(),
|
||||
addressLat: z.union([z.number(), z.string()]).nullable(),
|
||||
addressLng: z.union([z.number(), z.string()]).nullable(),
|
||||
});
|
||||
|
||||
export const isFieldAddressValue = (
|
||||
|
||||
Reference in New Issue
Block a user