{"id":17875968,"url":"https://github.com/bnjjj/tide-validator","last_synced_at":"2025-10-08T22:08:06.554Z","repository":{"id":48584590,"uuid":"248501149","full_name":"bnjjj/tide-validator","owner":"bnjjj","description":"A middleware working with Tide to validate your data coming from a request","archived":false,"fork":false,"pushed_at":"2021-07-19T14:50:18.000Z","size":26,"stargazers_count":15,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-31T07:37:15.547Z","etag":null,"topics":["api","http","middleware","rust","server","tide","validator","web"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnjjj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-19T12:47:03.000Z","updated_at":"2024-01-07T05:14:54.000Z","dependencies_parsed_at":"2022-09-26T20:40:36.379Z","dependency_job_id":null,"html_url":"https://github.com/bnjjj/tide-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bnjjj/tide-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Ftide-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Ftide-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Ftide-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Ftide-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnjjj","download_url":"https://codeload.github.com/bnjjj/tide-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnjjj%2Ftide-validator/sbom","scorecard":{"id":246043,"data":{"date":"2025-08-11","repo":{"name":"github.com/bnjjj/tide-validator","commit":"0286673d3524e6f1ec0a4d14fdf5a1c4c7fe75a8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/rust.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/bnjjj/tide-validator/rust.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/rust.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T07:38:07.030Z","repository_id":48584590,"created_at":"2025-08-17T07:38:07.030Z","updated_at":"2025-08-17T07:38:07.030Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000779,"owners_count":26082851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","http","middleware","rust","server","tide","validator","web"],"created_at":"2024-10-28T11:26:21.282Z","updated_at":"2025-10-08T22:08:06.522Z","avatar_url":"https://github.com/bnjjj.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003etide-validator\u003c/h1\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Crates version --\u003e\n  \u003ca href=\"https://crates.io/crates/tide-validator\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/tide-validator.svg?style=flat-square\"\n    alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- docs.rs docs --\u003e\n  \u003ca href=\"https://docs.rs/tide-validator\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\"\n      alt=\"docs.rs docs\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- github action status --\u003e\n  \u003ca href=\"https://github.com/bnjjj/tide-validator/actions?query=workflow%3ARust\"\u003e\n    \u003cimg src=\"https://github.com/bnjjj/tide-validator/workflows/Rust/badge.svg\"\n      alt=\"github action status\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n__tide-validator is a middleware working with [Tide](https://github.com/http-rs/tide), a web framework in Rust which let you validate your data coming from a request. You'll be able to create custom validators to validate your HTTP parameters, query parameters, cookies and headers.__\n\n# Features\n\n- __Custom validators:__ you can chain multiple validators and develop a custom validator is very easy. It's just a closure.\n- __Validate everything:__ with the enum `HttpField` you can validate different fields like cookies, headers, query parameters and parameters.\n- __Your own errors:__ thanks to generics in Rust you can use your own custom error when the data is invalid.\n    need.\n\n# Validators\n\nTo create your own validator it's just a closure to create with this form:\n\n```rust\n// The first closure's parameter is the parameter/queryparameter/cookie/header name.\n// The second parameter is the value of this HTTP element.\n// None means the field doesn't exist in the request (useful to force specific fields to be required).\nFn(\u0026str, Option\u003c\u0026str\u003e) -\u003e Result\u003c(), T\u003e + Send + Sync + 'static where T: Serialize + Send + Sync + 'static\n```\n\n# Documentation\n\nThe full documentation is available [here](https://docs.rs/tide-validator)\n\n# Examples\n\n+ __simple validation__\n```rust\n// Our own validator is a simple closure to check if the field is a number\nfn is_number(field_name: \u0026str, field_value: Option\u003c\u0026str\u003e) -\u003e Result\u003c(), String\u003e {\n    if let Some(field_value) = field_value {\n        if field_value.parse::\u003ci64\u003e().is_err() {\n            return Err(format!(\"field '{}' = '{}' is not a valid number\", field_name, field_value));\n        }\n    }\n\n    Ok(())\n}\n\n//... in main function\nlet mut app = tide::new();\nlet mut validator_middleware = ValidatorMiddleware::new();\n// 'age' is the parameter name inside the route '/test/:age'\nvalidator_middleware.add_validator(HttpField::Param(\"age\"), is_number);\n// You can assign different middleware for each routes therefore different validators for each routes\napp.at(\"/test/:age\")\n    .middleware(validator_middleware)\n    .get(|_: tide::Request\u003c()\u003e| async move {\n        let cat = Cat {\n            name: \"Gribouille\".into(),\n        };\n        tide::Response::new(StatusCode::Ok).body_json(\u0026cat).unwrap()\n     });\napp.listen(\"127.0.0.1:8080\").await?;\n```\n\n+ __chain multiple validators__\n```rust\n// This validator force element to be required\nfn is_required(field_name: \u0026str, field_value: Option\u003c\u0026str\u003e) -\u003e Result\u003c(), String\u003e {\n    if field_value.is_none() {\n        Err(format!(\"'{}' is required\", field_name))\n    } else {\n        Ok(())\n    }\n}\n\n// ... your main function\n\nlet mut app = tide::new();\nlet mut validator_middleware = ValidatorMiddleware::new();\n// Here 'age' is a query parameter, the validator stay the same as in previous example\nvalidator_middleware.add_validator(HttpField::QueryParam(\"age\"), is_number);\n// You can also add multiple validators on a single query parameter to check different things\nvalidator_middleware.add_validator(HttpField::QueryParam(\"age\"), is_required);\n\n// You can assign different middleware for each routes therefore different validators for each routes\napp.at(\"/test\")\n    .middleware(validator_middleware)\n    .get(|_: tide::Request\u003c()\u003e| async move {\n           let cat = Cat {\n                name: \"Mozart\".into(),\n           };\n            tide::Response::new(StatusCode::Ok).body_json(\u0026cat).unwrap()\n        },\n    );\n\napp.listen(\"127.0.0.1:8080\").await?;\n```\n\n+ __Use your own custom error__\n```rust\n// Your custom error which your api will send if an error occurs\n#[derive(Debug, Serialize)]\nstruct CustomError {\n    status_code: usize,\n    message: String,\n}\n\n// Your validator can also return your own error type\nfn is_number(field_name: \u0026str, field_value: Option\u003c\u0026str\u003e) -\u003e Result\u003c(), CustomError\u003e {\n    if let Some(field_value) = field_value {\n        if field_value.parse::\u003ci64\u003e().is_err() {\n            return Err(CustomError {\n                status_code: 400,\n                message: format!(\n                    \"field '{}' = '{}' is not a valid number\",\n                    field_name, field_value\n                ),\n            });\n        }\n    }\n    Ok(())\n}\n\n// ... your main function\n```\n\n+ __Dynamic validators__\n```rust\n// Validator inside a function as a closure to be dynamic with max_length\nfn is_length_under(\n    max_length: usize,\n) -\u003e Box\u003cdyn Fn(\u0026str, Option\u003c\u0026str\u003e) -\u003e Result\u003c(), CustomError\u003e + Send + Sync + 'static\u003e {\n    Box::new(\n        move |field_name: \u0026str, field_value: Option\u003c\u0026str\u003e| -\u003e Result\u003c(), CustomError\u003e {\n            if let Some(field_value) = field_value {\n                if field_value.len() \u003e max_length {\n                    let my_error = CustomError {\n                        status_code: 400,\n                        message: format!(\n                            \"element '{} which is equals to '{}' have not the maximum length of {}\",\n                            field_name, field_value, max_length\n                        ),\n                    };\n                    return Err(my_error);\n                }\n            }\n            Ok(())\n        },\n    )\n}\n\n// Simply call it on a cookie `session` for example:\nvalidator_middleware.add_validator(HttpField::Cookie(\"session\"), is_length_under(20));\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnjjj%2Ftide-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnjjj%2Ftide-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnjjj%2Ftide-validator/lists"}