diff --git a/CHANGELOG.md b/CHANGELOG.md index 9642619..8b936d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/names.rs b/src/names.rs index 2799c6b..5f67f68 100644 --- a/src/names.rs +++ b/src/names.rs @@ -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