Skip to content

fix: do not skip parameter validation if min or max = 0 #7707

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

Merged
merged 6 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: site
  • Loading branch information
mtojek committed May 30, 2023
commit d507f9d8143abe9ab9b9d2780c90dff69ac1e7ec
2 changes: 2 additions & 0 deletions site/src/i18n/en/createWorkspacePage.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"nameLabel": "Workspace Name",
"ownerLabel": "Owner",
"createWorkspace": "Create workspace",
"validationNumberNotLesserThan": "Value must be greater than {{min}}.",
"validationNumberNotGreaterThan": "Value must be lesser than {{max}}.",
"validationNumberNotInRange": "Value must be between {{min}} and {{max}}.",
"validationPatternNotMatched": "{{error}} (value does not match the pattern {{pattern}})."
}
24 changes: 24 additions & 0 deletions site/src/utils/richParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ export const useValidationSchemaForRichParameters = (
switch (templateParameter.type) {
case "number":
if (
templateParameter.validation_min &&
!templateParameter.validation_max
) {
if (Number(val) < templateParameter.validation_min) {
return ctx.createError({
path: ctx.path,
message: t("validationNumberLesserThan", {
min: templateParameter.validation_min,
}),
})
}
} else if (
!templateParameter.validation_min &&
templateParameter.validation_max
) {
if (templateParameter.validation_max < Number(val)) {
return ctx.createError({
path: ctx.path,
message: t("validationNumberGreaterThan", {
max: templateParameter.validation_max,
}),
})
}
} else if (
templateParameter.validation_min &&
templateParameter.validation_max
) {
Expand Down