validate_npm_package_name

Crates.iovalidate_npm_package_name
lib.rsvalidate_npm_package_name
version0.1.0
sourcesrc
created_at2024-10-10 16:41:11.775374
updated_at2024-10-10 16:41:11.775374
descriptionA crate to validate npm package name
homepagehttps://github.com/Chersquwn/validate_npm_package_name
repositoryhttps://github.com/Chersquwn/validate_npm_package_name
max_upload_size
id1404023
size16,273
shaoqun lin (Chersquwn)

documentation

README

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"
    )])
}
Commit count: 3

cargo fmt