From a494e7f7f10799f3cdee8cfb78909c842295e78f Mon Sep 17 00:00:00 2001 From: Thomas Lund Fagermyr <35408743+thomaslf97@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:44:06 +0200 Subject: [PATCH] feat: Added validation for area model (#337) --- .../AreaCoordinates/hooks/AreaCoordinates.hooks.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/AreaCoordinates/hooks/AreaCoordinates.hooks.ts b/src/components/AreaCoordinates/hooks/AreaCoordinates.hooks.ts index 71039b4..7fcece8 100644 --- a/src/components/AreaCoordinates/hooks/AreaCoordinates.hooks.ts +++ b/src/components/AreaCoordinates/hooks/AreaCoordinates.hooks.ts @@ -22,6 +22,12 @@ export const validateCoordinates = async ( errors.area = 'You must select a model area'; } + if (area && area.coordinates[0].x > area.coordinates[1].x) { + errors.x0 = 'X start cannot be greater than X end.'; + } + if (area && area.coordinates[0].y > area.coordinates[1].y) { + errors.y0 = 'Y start cannot be greater than Y end.'; + } if (area && area.coordinates[0].x === area.coordinates[1].x) { errors.x0 = "X start/end coordinates can't be equal."; }