diff --git a/govtool/frontend/src/consts/governanceAction/fields.ts b/govtool/frontend/src/consts/governanceAction/fields.ts index daf66244f..1dbe762c1 100644 --- a/govtool/frontend/src/consts/governanceAction/fields.ts +++ b/govtool/frontend/src/consts/governanceAction/fields.ts @@ -119,9 +119,21 @@ export const GOVERNANCE_ACTION_FIELDS: GovernanceActionFields = { value: true, message: I18n.t("createGovernanceAction.fields.validations.required"), }, - validate: (value) => - Number.isInteger(Number(value)) || - I18n.t("createGovernanceAction.fields.validations.number"), + validate: (value) => { + const parsedValue = Number( + value.includes(",") ? value.replace(",", ".") : value + ); + + if (isNaN(parsedValue)) { + return I18n.t("createGovernanceAction.fields.validations.number"); + } + + if (parsedValue < 0) { + return I18n.t("createGovernanceAction.fields.validations.positive"); + } + + return true; + }, }, }, }, diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index b32f08b3b..166d05af5 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -175,6 +175,7 @@ export const en = { number: "Only number is allowed", required: "This field is required", url: "Invalid URL", + positive: "Only positive number is allowed", }, }, formTitle: "Governance Action details",