Skip to content

models/krate: Move URL and name validation out of create_or_update() #7185

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 7 commits into from
Sep 26, 2023

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Sep 26, 2023

The reserved name and URL validations are somewhat unrelated to the NewCrate struct and are much more useful as independent validations, that can be run in combination with some of the other publish validations that we have (e.g. missing/empty metadata fields or the Cargo.toml content validation).

This PR extracts that functionality and moves it to the publish module instead.

`create_or_update()` is only called in four places. Three of them are within test code, where a `create()` fn would be sufficient and where we don't necessarily need the same kind of validation. The fourth place is the publish endpoint, where this validation is definitely needed, but could potentially be combined with other validation code in the future.
This function does not need to be on the `NewCrate` struct, since the only relevant field is `name` and we can pass that in as a `&str` instead.
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Sep 26, 2023
This function does not need to be on the `NewCrate` struct. Making it independent from the struct allows us to perform this validation much earlier in the process and combine it with other validations.
@Turbo87 Turbo87 merged commit 65e31bc into rust-lang:main Sep 26, 2023
@Turbo87 Turbo87 deleted the publish-validation branch September 26, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant