feat: remove lower bound limit on pesde package name length

This commit is contained in:
daimond113 2024-12-14 17:41:57 +01:00
parent 919b0036e5
commit 9ee75ec9c9
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 20 additions and 5 deletions

View file

@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Add Roblox types in linker modules even with no config generator script by @daimond113
### Changed
- Remove lower bound limit of 3 characters for pesde package names by @daimond113
## [0.5.0-rc.18] - 2024-12-12
### Fixed
- Correctly resolve URLs in `publish` command by @daimond113

View file

@ -35,8 +35,16 @@ impl FromStr for PackageName {
.ok_or(Self::Err::InvalidFormat(s.to_string()))?;
for (reason, part) in [(ErrorReason::Scope, scope), (ErrorReason::Name, name)] {
if part.len() < 3 || part.len() > 32 {
return Err(Self::Err::InvalidLength(reason, part.to_string()));
let min_len = match reason {
ErrorReason::Scope => 3,
ErrorReason::Name => 1,
};
if !(min_len..=32).contains(&part.len()) {
return Err(match reason {
ErrorReason::Scope => Self::Err::InvalidScopeLength(part.to_string()),
ErrorReason::Name => Self::Err::InvalidNameLength(part.to_string()),
});
}
if part.chars().all(|c| c.is_ascii_digit()) {
@ -231,9 +239,13 @@ pub mod errors {
#[error("package {0} `{1}` starts or ends with an underscore")]
PrePostfixUnderscore(ErrorReason, String),
/// The package name is not within 3-32 characters long
#[error("package {0} `{1}` is not within 3-32 characters long")]
InvalidLength(ErrorReason, String),
/// The package name's scope part is not within 3-32 characters long
#[error("package scope `{0}` is not within 3-32 characters long")]
InvalidScopeLength(String),
/// The package name's name part is not within 1-32 characters long
#[error("package name `{0}` is not within 1-32 characters long")]
InvalidNameLength(String),
}
/// Errors that can occur when working with Wally package names