chrisbuchholz / accord Goto Github PK
View Code? Open in Web Editor NEWData validation library for Rust
License: MIT License
Data validation library for Rust
License: MIT License
Currently there's no timeline for stabilization of impl trait. What do you think about moving the current validators behind a nightly
feature gate, and returning boxed closures when that feature is not enabled?
Right now, to integrate with Rocket one has to set up a few things, most notable is the FromData implementation that is needed. It can be seen here: https://github.com/ChrisBuchholz/accord/blob/master/examples/rocket/src/account.rs#L25-L38
If possible, one should be able to derive
it or something since those 13 lines will be the same needed for every Type
in your Rocket application that uses Accord.
If you're looking for an idea for something to do, I think it would be pretty cool if I could:
#[derive(AccordValidate)]
struct Account {
#[accord_rule(length(1..64))]
name: String,
#[accord_rule(length(5..64), contains("@"), contains("."))]
email: String,
#[accord_rule(range(12..127))]
age: i8,
}
And get an auto-impld Account::validate
function. A similar thing like derive(AccordNew)
or AccordBuilder
seem like something that would also be nice so that it's impossible to even build invalid objects in the common case.
I'm really not sure about this, since it's easy to make an email validator too restrictive so as to hit false on obscure but valid urls.
The only real examples right now focuses of use in a REST API setting. There should be examples showcasing other scenarios.
I'm really not sure about this, since it's easy to make an URL validator too restrictive so as to hit false on obscure but valid urls.
Right now, the only way to test both accord and its examples is to run cargo test
in both the accord crate and the bundled example crates. Introducing a Makefile to handle testing could reduce this to a single stop of make test
.
Range
is defined in Rust as half-open: so 12..127
means “at least 12, and less than 127”. In your validators you’ve implemented it with incorrect semantics, treating it as an inclusive range, which is instead 12...127
(and experimental).
The patter used to implement length
and range
validators using RangeInclusive
is ugly; especially the panic here: https://github.com/ChrisBuchholz/accord/blob/master/src/validators.rs#L74
Find a better way.
Being able to derive support for FromForm for Validated<T> where T: Accord + Validated
and FromData
would make Rocket integration much simpler.
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.