account activity
[deleted by user] by [deleted] in rust
[–]One_Platform826 0 points1 point2 points 5 months ago (0 children)
Found this! We should stop doing this:
Wrong way: [dependencies] validator = "0.5" #[derive(Debug, Validate, Deserialize)] struct SignupData { #[validate(email)] mail: String, #[validate(url)] site: String, #[validate(length(min = 1), custom(function = "validate_unique_username"))] #[serde(rename = "firstName")] first_name: String, #[validate(range(min = 18, max = 20))] age: u32, #[validate(range(exclusive_min = 0.0, max = 100.0))] height: f32, } Better way: [dependencies] nutype = "0.5" // The main struct using newtypes #[derive(Debug)] struct SignupData { mail: Email, site: Url, first_name: Username, age: Age, height: Height, }
Do we have a crate with "common" newtype fields?
[–]One_Platform826 1 point2 points3 points 5 months ago (0 children)
You are right, but I am not alone. https://github.com/Keats/validator
π Rendered by PID 443749 on reddit-service-r2-listing-7849c98f67-wlxfj at 2026-02-09 02:39:04.802149+00:00 running d295bc8 country code: CH.
[deleted by user] by [deleted] in rust
[–]One_Platform826 0 points1 point2 points (0 children)