Skip to content

Commit 7a9b056

Browse files
authored
FEAT: Rust Email Script Added (HarshCasper#1312)
1 parent 00c4004 commit 7a9b056

File tree

5 files changed

+191
-1
lines changed

5 files changed

+191
-1
lines changed

Rust/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# Rust
1+
<div align="center"><img src="https://user-images.githubusercontent.com/79367883/156792782-fa762f01-183f-4ab5-ae61-d333b052bff9.png" alt="Rust_Logo" /></div>
22

3+
## Rust Scripts associated with this project:
4+
5+
- [Youtube_Downloader](./Youtube_Downloader/)
6+
- [Email_Validator](./email-validator/)

Rust/email-validator/Cargo.lock

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rust/email-validator/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "email-validator"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
regex = "1"
10+
colored = "2"

Rust/email-validator/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Email Validator
2+
3+
This Rust Script will apply checks on the Email Addresses which in case turns out to be invalid then we can throw errors and add this feature wherever we think of using Rust as Backend.
4+
5+
## Install
6+
7+
- Get the file on your System.
8+
- Setup Cargo
9+
- Run `Cargo run` and you are good to go.
10+
11+
## Dependencies
12+
13+
Script depends on the following crates (downloaded automatically by cargo):
14+
15+
- `regex`
16+
- `colored`
17+
18+
## Running
19+
20+
Build the project using `cargo build`. The binary will be present in `./target/debug/ytdl`.
21+
22+
## Author
23+
24+
Harshil Jani

Rust/email-validator/src/main.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
extern crate regex;
2+
extern crate colored;
3+
use std::io;
4+
use regex::Regex;
5+
use colored::*;
6+
7+
fn main() {
8+
println!("Enter your E-mail Address : ");
9+
let mut mail = String::new();
10+
io::stdin().read_line(&mut mail).expect("Provide Valid Mail ID !");
11+
let chunks: Vec<_> = mail.split('@').collect();
12+
let mut count : u32 = 0;
13+
let mut pre;
14+
let mut post;
15+
for s in chunks{
16+
if count==2 {
17+
println!("{}","Invalid Mail ID".red());
18+
return
19+
}
20+
if count==0 {
21+
pre = s;
22+
let mut pre_check : bool;
23+
let pre_regex = Regex::new(r"^[A-Za-z]+").unwrap();
24+
pre_check = pre_regex.is_match(pre);
25+
if pre_check == false {
26+
println!("{}","Email Address Must start with a character word only !".red());
27+
return
28+
}
29+
}else{
30+
post = s;
31+
let domains: Vec<_> = post.split('.').collect();
32+
for domain in domains{
33+
let post_regex = Regex::new(r"^[a-z]+$|\n$").unwrap();
34+
let post_check = post_regex.is_match(domain);
35+
if post_check == false{
36+
println!("{}","The Domain name is not allowed !".red());
37+
return
38+
}
39+
}
40+
}
41+
count += 1;
42+
}
43+
println!("{}","The Email Address Provided is available".green());
44+
}

0 commit comments

Comments
 (0)