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

fix: [M3-8466] - Improve validation rules for create bucket schema #10842

Merged
merged 3 commits into from
Aug 28, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Fixed
---

Error validation for letter casing when creating object storage bucket now correctly appears for labels. ([#10842](https://github.com/linode/manager/pull/10842))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error validation for letter casing when creating object storage bucket now correctly appears for labels. ([#10842](https://github.com/linode/manager/pull/10842))
Lack of `label` error validation for letter casing when creating Object Storage bucket ([#10842](https://github.com/linode/manager/pull/10842))

Suggestion is based on our best practices:

For Fixed changesets, describe the bug that needed to be fixed, rather than the fix itself. (e.g. say "Missing button labels in action buttons" rather than "Make label prop required for action buttons").

Begin a changeset with a capital letter, but do not end it with a period; it's not a complete sentence.

4 changes: 4 additions & 0 deletions packages/validation/src/buckets.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const CreateBucketSchema = object()
label: string()
.required('Label is required.')
.matches(/^\S*$/, 'Label must not contain spaces.')
.matches(
/^[a-z0-9.-]*$/,
'Label must consist only of lowercase letters, numbers, . (period), and - (dash).'
Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check for the restriction that names cannot have adjacent periods or dashes?

The following regex could work for that: ^(?!.*[.-]{2})[a-z0-9.-]+$

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They also can't start with anything but a letter or a number, though that's more of an edge case like the above.

image

)
.min(3, 'Label must be between 3 and 63 characters.')
.max(63, 'Label must be between 3 and 63 characters.')
.test(
Expand Down
Loading