Skip to content

fix: CreateWorkspaceForm name validation #1453

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 2 commits into from
May 16, 2022
Merged
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
Next Next commit
refactor: allow helperText in getFormHelpers
By passing in helperText, we will not accidentally overwrite it.
  • Loading branch information
greyscaled committed May 14, 2022
commit eeb29ca6762518d50bccb72188cc8bd4fb104be8
4 changes: 2 additions & 2 deletions site/src/util/formUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface FormHelpers {

export const getFormHelpers =
<T>(form: FormikContextType<T>, formErrors?: FormikErrors<T>) =>
(name: keyof T): FormHelpers => {
(name: keyof T, helperText = ""): FormHelpers => {
if (typeof name !== "string") {
throw new Error(`name must be type of string, instead received '${typeof name}'`)
}
Expand All @@ -28,7 +28,7 @@ export const getFormHelpers =
...form.getFieldProps(name),
id: name,
error: touched && Boolean(error),
helperText: touched && error,
helperText: touched ? error : helperText,
}
}

Expand Down