-
Notifications
You must be signed in to change notification settings - Fork 16
validate-stack-name-regexp #915
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
base: staging
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| import { validateStackName } from "@/lib/stacks"; | ||
| import { validateStackNameNotInUse } from "@/lib/stacks"; | ||
| import { z } from "zod"; | ||
|
|
||
| export const stackNameSchema = z | ||
| .string() | ||
| .trim() | ||
| .min(1, "Stack name is required") | ||
| .max(255, "Stack name must be less than 255 characters") | ||
| .refine((name) => validateStackName(name), "Stack name is already in use"); | ||
| .max(32, "Stack name must be less than 32 characters") | ||
| .refine((name) => validateStackNameNotInUse(name), "Stack name is already in use") | ||
|
||
| .refine( | ||
| (name) => name.match(/^[a-zA-Z0-9-]+$/), | ||
| "Stack name can only contain only letters, numbers and dashes" | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { fetchStacks } from "@/data/stacks/stacklist-query"; | ||
| import AwesomeDebouncePromise from "awesome-debounce-promise"; | ||
|
|
||
| export const validateStackName = AwesomeDebouncePromise(async (name: string) => { | ||
| export const validateStackNameNotInUse = AwesomeDebouncePromise(async (name: string) => { | ||
| const data = await fetchStacks({ name }); | ||
| return data.total === 0; | ||
| }, 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you come to the conclusion of this?
I just checked the Swagger-Docs and the only restriction is the length of 255 characters that we had before 🤔
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the designs it was 32, but yes, api is king, so back to 255