Email addresses
Email addresses checked against RFC 5322 and split into local part, domain and display name.
Version 1.0.0 · 2 functions · 1 crate
Functions
What use email_address.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use email_valid, email_parts from email_address (Quillo 0.6).
email_valid(address: str) → boolWhether address is a well-formed email address. (Whether it receives mail, only sending one tells.)
email_parts(address: str) → anyor an error{ local, domain, display, address } of an address, Ada <ada@example.com> too; the domain in lower case.
Get it
$ quillo install email_address # email_address.qwer into this folder$ quillo install email_address --example # and its example, email_address.qweOr with curl:
$ curl -O https://quillolang.org/plugins/files/email_address.qwer$ curl -O https://quillolang.org/plugins/files/email_address.qweThen, in your program, all of it or only what you call:
use email_address.qweruse email_valid, email_parts from email_address // Quillo 0.6: only theseIt uses this crate, which cargo fetches the first time the plugin is built:
email_address = "0.2"Example
// Checking the address in a sign-up form.//// quillo run email_address.qwe then open http://localhost:8080/check?email=ada@Example.COMuse "email_address.qwer"route GET /check ? { email: str } = email_valid(email) ? email_parts(email)? : { error: "That is not an email address" }route GET /samples = { good: email_valid("ada@example.com"), bad: email_valid("ada@@example"), named: email_parts("Ada Lovelace <ada@Example.com>")? }$ quillo run email_address.qwe$ curl 'localhost:8080/check?email=ada@Example.COM'$ curl 'localhost:8080/samples'Source
//! Email addresses checked against RFC 5322 and split into their parts, display names included.//! version: 1.0.0//!//! [dependencies]//! email_address = "0.2"use email_address::EmailAddress;use serde_json::{json, Value};use std::str::FromStr;/// Whether `address` is a well-formed email address. (Whether it receives mail, only sending one tells.)pub fn email_valid(address: &str) -> bool { EmailAddress::is_valid(address.trim())}/// `{ local, domain, display, address }` of an address, `Ada <ada@example.com>` too; the domain in lower case.pub fn email_parts(address: &str) -> Result<Value, String> { let e = EmailAddress::from_str(address.trim()).map_err(|e| e.to_string())?; let domain = e.domain().to_lowercase(); Ok(json!({ "local": e.local_part(), "domain": domain, "display": e.display_part(), "address": format!("{}@{}", e.local_part(), domain) }))}Related
pdf_forms.qwer · 1.0.0PDF forms: the fields listed with their types, values and choices, filled from a map with their appearances drawn, and flattened so they cannot be changed.8 views · 6 downloadsCaptcha captcha.qwer · 1.0.0Picture captchas made on your own server: distorted letters as a PNG data URL and the answer to keep in the session.7 views · 6 downloadsPassword strength password_strength.qwer · 1.0.0How guessable a password is (zxcvbn): a score from 0 to 4, a warning and suggestions, and how long it would take to crack.6 views · 8 downloadsCard numbers cards.qwer · 1.0.0Payment card numbers checked before they reach a payment provider: Luhn check digit, brand and length, expiry, and the number formatted or masked for receipts.7 views · 7 downloadsCountries countries.qwer · 1.0.0ISO 3166 countries for forms and addresses: alpha-2, alpha-3 and numeric codes, names in several languages, calling codes, flags, continents, currencies and EU membership.9 views · 7 downloadsCurrencies currencies.qwer · 1.0.0ISO 4217 currencies: names, symbols, minor units and the countries using them, prices formatted, and amounts turned into the cents payment APIs take.6 views · 7 downloadsThread 0 posts
On Email addresses: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.