diff --git a/back/src/forms/__tests__/validation.integration.ts b/back/src/forms/__tests__/validation.integration.ts index 7bc94ee4f2..aaf78c1d77 100644 --- a/back/src/forms/__tests__/validation.integration.ts +++ b/back/src/forms/__tests__/validation.integration.ts @@ -1275,6 +1275,22 @@ describe("draftFormSchema", () => { expect(isValid).toBe(true); }); + it("should be valid when passing a parcelNumber negative coordinates", async () => { + const isValid = await draftFormSchema.isValid({ + ...form, + wasteDetailsParcelNumbers: [ + { + city: "Paris", + postalCode: "750012", + x: -1.2, + y: -1.3 + } + ] + }); + + expect(isValid).toBe(true); + }); + it("should be invalid when passing an incomplete parcelNumber number", async () => { const validateFn = () => draftFormSchema.validate({ diff --git a/back/src/forms/validation.ts b/back/src/forms/validation.ts index 8435604806..42ce868f20 100644 --- a/back/src/forms/validation.ts +++ b/back/src/forms/validation.ts @@ -650,7 +650,7 @@ const parcelNumber = yup.object({ .max(5) .required("Parcelle: le numéro de parcelle est obligatoire") }); -const patternSixDigisAfterComma = /^\d+(\.\d{0,6})?$/; +const patternSixDigisAfterComma = /^[-+]?\d+(\.\d{0,6})?$/; const parcelCoordinates = yup.object({ x: yup .number()