See validators/README.md.
magiclen / validators Goto Github PK
View Code? Open in Web Editor NEWA library for validating and modeling user input.
License: MIT License
A library for validating and modeling user input.
License: MIT License
See validators/README.md.
Hi, thanks for this library!
I was thinking about adding a validator for color RGB hex codes, which are widely used in the web.
e.g. the validator should accept #00ff44, maybe the CSS spec would be useful there.
Hi,
发现错误,代码如下
use validators::prelude::*;
#[derive(Validator)]
#[validator(uuid(case(Upper), separator(Allow(hyphen))))]
pub struct UUID(pub u128);
pub async fn index() -> Json<ResResult> {
assert!(UUID::parse_string("A866664AF9D34DDE89CB182015FA4F41").is_ok());
assert!(UUID::parse_string("A866664A-F9D3-4DDE-89CB-182015FA4F41").is_ok());
//这个不支持?
assert!(UUID::parse_string("405464eb-de93-44cc-bb08-72635f66d6cd").is_ok());
let result = ResResult {
code: 200,
msg: "ok".to_string(),
result: "1212121".to_string(),
};
Json(result)
}
版本:
validators = "0.24.3"
错误信息
thread 'tokio-runtime-worker' panicked at 'assertion failed: UUID::parse_string(\"405464eb-de93-44cc-bb08-72635f66d6cd\").is_ok()', src/handler/home.rs:196:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The crate does not support multiple validators at the same time it seems?
#[derive(Validator, Debug, Clone)]
#[validator(line(char_length(min = 5, max = 35),regex(regexs::USERNAME_REG))]
pub struct Username(String);
does not compile and
#[derive(Validator, Debug, Clone)]
#[validator(regex(regexs::USERNAME_REG))]
#[validator(line(char_length(min = 5, max = 35)))]
pub struct Username(String);
doesn't work, only the top one is selected
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.