1 unstable release
0.1.0 | Oct 10, 2024 |
---|
#3 in #true
Used in npm_pkg
7KB
92 lines
validate_npm_package_name
A crate to validate npm package name
Install
cargo add validate_npm_package_name
Usage
Valid Names
use validate_npm_package_name::validate;
validate(&String::from("some-package"));
validate(&String::from("@npm/abc"));
Validate Result
validate_npm_package_name::ValidateResult {
valid_for_new_packages: true,
valid_for_old_packages: true,
warnings: None,
errors: None
}
Invalid Names
use validate_npm_package_name::validate;
validate(&String::from("s/l/a/s/h/e/s"));
Validate Result
validate_npm_package_name::ValidateResult {
valid_for_new_packages: true,
valid_for_old_packages: true,
warnings: None,
errors: Some(vec![String::from(
"name can only contain URL-friendly characters"
)])
}
Dependencies
~2.2–3MB
~55K SLoC