From 86fe2ed30f3c0494306c38713a6f96e856eb003a Mon Sep 17 00:00:00 2001 From: hatim dinia Date: Wed, 29 Nov 2023 15:28:38 +0100 Subject: [PATCH] feat(ui-model): add validation rules for thermal renewable and storage forms --- .../Modelization/Areas/Renewables/Fields.tsx | 12 +++ .../Modelization/Areas/Storages/Fields.tsx | 38 ++++++++ .../Modelization/Areas/Thermal/Fields.tsx | 86 +++++++++++++++++++ 3 files changed, 136 insertions(+) diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/Fields.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/Fields.tsx index 6f60db0fbb..1e49ed3f97 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/Fields.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Renewables/Fields.tsx @@ -61,11 +61,23 @@ function Fields() { label={t("study.modelization.clusters.unitcount")} name="unitCount" control={control} + rules={{ + min: { + value: 1, + message: t("form.field.minValue", { 0: 1 }), + }, + }} /> diff --git a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/Fields.tsx b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/Fields.tsx index 3008f21406..0e04b378a0 100644 --- a/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/Fields.tsx +++ b/webapp/src/components/App/Singlestudy/explore/Modelization/Areas/Storages/Fields.tsx @@ -43,6 +43,12 @@ function Fields() { label={t("study.modelization.storages.injectionNominalCapacity")} name="injectionNominalCapacity" control={control} + rules={{ + min: { + value: 0, + message: t("form.field.minValue", { 0: 0 }), + }, + }} /> @@ -56,6 +62,12 @@ function Fields() { label={t("study.modelization.storages.withdrawalNominalCapacity")} name="withdrawalNominalCapacity" control={control} + rules={{ + min: { + value: 0, + message: t("form.field.minValue", { 0: 0 }), + }, + }} /> @@ -69,6 +81,12 @@ function Fields() { label={t("study.modelization.storages.reservoirCapacity")} name="reservoirCapacity" control={control} + rules={{ + min: { + value: 0, + message: t("form.field.minValue", { 0: 0 }), + }, + }} /> @@ -77,11 +95,31 @@ function Fields() { label={t("study.modelization.storages.efficiency")} name="efficiency" control={control} + rules={{ + min: { + value: 0, + message: t("form.field.minValue", { 0: 0 }), + }, + max: { + value: 1, + message: t("form.field.maxValue", { 0: 1 }), + }, + }} />
@@ -99,21 +141,45 @@ function Fields() { label={t("study.modelization.clusters.marginalCost")} name="marginalCost" control={control} + rules={{ + min: { + value: 0, + message: t("form.field.minValue", { 0: 0 }), + }, + }} />