4 releases
0.1.7 | Apr 4, 2023 |
---|---|
0.1.6 |
|
0.1.5 | Apr 4, 2023 |
0.1.1 | Mar 25, 2023 |
0.1.0 | Mar 25, 2023 |
#1594 in Text processing
54 downloads per month
54KB
120 lines
polyvalid
polyvalid
is a Rust library for validating package names, usernames, namespace names, and app names. The library provides a single source of truth for validating the names with the following rules:
- Start with an alphabet character
- Have one or more alphanumeric characters,
_
or-
- End with an alphanumeric character
Additionally, the library checks if the name contains --
since it can break URL rules.
The library can be used from Python and JS through the provided bindings.
Using the library
The library can be used from rust, python or javascript. The following describes how to use it from all three languages.
Rust
cargo add polyvalid
use polyvalid;
let name: String = "polyvalid";
assert!(polyvalid::is_app_name_valid(name));
Python
pip add polyvalid
import polyvalid
name = "polyvalid"
polyvalid.is_app_name_valid(name) # returns True
Javascript
npm i polyvalid
import "polyvalid";
name = "polyvalid";
polyvalid.is_valid_name(name); // returns true
Next steps
- Add CI to autopublish to wapm, pypi, npm
- Add tests for python and JS versions of the library
- Add wrapper around the python library (to improve usability)
Contributing
Contributions are welcome! If you'd like to contribute to polyvalid
, please follow these steps:
- Fork the repo and create a new branch for your changes.
- Make your changes, write tests, and ensure that the tests pass.
- Submit a pull request to the
polyvalid
repo. - Wait for feedback or approval from the maintainers.
Dependencies
~3.5–5MB
~94K SLoC