#url #validation #valid #scheme #https #ftp #characters

yanked url_validator

A Rust crate for URL validation

4 releases

0.1.4 Nov 2, 2023
0.1.3 Nov 2, 2023
0.1.2 Nov 2, 2023
0.1.1 Nov 1, 2023
0.1.0 Nov 1, 2023

#44 in #ftp

24 downloads per month

MIT license

7KB
76 lines

URL Validator

A Rust crate for URL validation.

License: MIT Crates.io Docs.rs

Introduction

URL Validator is a simple and lightweight Rust crate that allows you to check if a given string is a valid URL according to specific criteria. It's useful for ensuring that URLs in your Rust applications and scripts meet certain standards.

Features

  • Validates URLs based on the following criteria:
    • URL must contain a valid scheme (e.g., "http", "https", "ftp").
    • Scheme and the rest of the URL cannot be empty.
    • URL must contain "://" exactly once.
    • The rest of the URL should consist of valid characters: alphanumeric, '.', '-', ':', and '/'.
  • Easy integration into your Rust projects.

Installation

To use this crate in your Rust project, add it as a dependency in your Cargo.toml:

[dependencies]
url_validator = "0.1.4"

Usage

Incorporate this crate into your Rust application to perform URL validation. The primary function, is_valid_url, returns true if the URL is valid and false otherwise.

extern crate url_validator;

use url_validator::is_valid_url;

fn main() {
    let url = "https://www.example.com";
    let is_valid = is_valid_url(url);

    if is_valid {
        println!("Valid URL: {}", url);
    } else {
        println!("Invalid URL: {}", url);
    }
}

Contributing

Contributions to this project are welcome. If you have any ideas for improvements, new features, or bug fixes, feel free to open an issue or submit a pull request on GitHub.

License

This crate is open-source and available under the MIT License. You can use it in your projects for free and modify it according to your needs.

Enjoy using URL Validator in your Rust projects! If you have any questions or encounter issues, don't hesitate to reach out.

No runtime deps