Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#377] fix: validation of ada amount #490

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions govtool/frontend/src/consts/governanceAction/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down