Compare commits

...

1 Commits

Author SHA1 Message Date
Sonarly Claude Code f1a8d1a807 fix: accept string lat/lng in address field validation
The addressLat and addressLng sub-fields use FieldMetadataType.NUMERIC
which maps to PostgreSQL's numeric column type. The pg driver returns
numeric values as strings to preserve precision, but the zod validation
schema in isFieldAddressValue only accepted z.number(). This caused
"Invalid value to persist" errors when users edited address fields
on records that had previously saved lat/lng coordinates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 23:33:30 +00:00
2 changed files with 17 additions and 2 deletions
@@ -34,6 +34,21 @@ describe('isFieldAddressValue', () => {
).toBe(true);
});
it('should return true for address with string lat/lng from numeric db column', () => {
expect(
isFieldAddressValue({
addressStreet1: 'England',
addressStreet2: '',
addressCity: '',
addressState: 'England',
addressPostcode: '',
addressCountry: 'United Kingdom',
addressLat: '52.83816401015793',
addressLng: '-2.327480843616569',
}),
).toBe(true);
});
it('should return false for incomplete address', () => {
expect(isFieldAddressValue({ addressStreet1: '123 Main St' })).toBe(false);
});
@@ -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 = (