Skip to content

Commit

Permalink
fix: adding negative numbers to regex
Browse files Browse the repository at this point in the history
  • Loading branch information
GaelFerrand committed Jun 13, 2024
1 parent 2cf185e commit 6a1917c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions back/src/forms/__tests__/validation.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion back/src/forms/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6a1917c

Please sign in to comment.