GithubHelp home page GithubHelp logo

validators's Introduction

validators's People

Contributors

dependabot[bot] avatar magiclen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

icodein dilawar

validators's Issues

add color (hex) validator

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.

axum==0.5.17 check uuid 报错

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

Multiple validators?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.