6
1
Fork
You've already forked yourevalid
0
you just are! validation type and trait for sonata and polyproto-rs
  • Nix 67.8%
  • Rust 30.2%
  • Shell 2%
Flori Ava Star Weber 6603f5d1d7
Some checks failed
Rust: Security: Automated dependency analysis / cargo-deny (push) Failing after 45s
Build legacy Nix package on Ubuntu / build (push) Failing after 16s
General: License headers and identifiers / license-headers (push) Successful in 4s
Rust: Compliance / Run rust-clippy analyzing (push) Successful in 1m9s
Rust: Build, Test, Publish Coverage / linux (push) Failing after 7m28s
faggotry :3
2026年01月04日 02:10:30 +01:00
.github fix: install cargo-deny with cargo-binstall and specify absolute path to it 2026年01月02日 15:09:52 +03:00
.vscode fix: nixEnvSelector required flakes to be activated 2025年12月24日 14:26:09 +01:00
modules fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
packages fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
scripts initial commit 2025年11月09日 17:36:51 +01:00
src feat: major changes for alpha.3 2026年01月04日 02:10:20 +01:00
template fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
.envrc initial commit 2025年11月09日 17:36:51 +01:00
.gitattributes initial commit 2025年11月09日 17:36:51 +01:00
.gitignore feat: wauwau 2025年11月09日 18:11:57 +01:00
.pre-commit-config.yaml fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
Cargo.lock feat: major changes for alpha.3 2026年01月04日 02:10:20 +01:00
Cargo.toml feat: major changes for alpha.3 2026年01月04日 02:10:20 +01:00
default.nix feat: add rustfmt, run nix fmt, update toolchain 2025年12月24日 14:26:09 +01:00
deny.toml initial commit 2025年11月09日 17:36:51 +01:00
flake-module.nix fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
flake.lock fix: run on polyphony runners 2025年12月24日 14:26:09 +01:00
flake.nix feat: add rustfmt, run nix fmt, update toolchain 2025年12月24日 14:26:09 +01:00
README.md faggotry :3 2026年01月04日 02:10:30 +01:00
rust-toolchain.toml feat: add rustfmt, run nix fmt, update toolchain 2025年12月24日 14:26:09 +01:00
rustfmt.toml feat: add rustfmt, run nix fmt, update toolchain 2025年12月24日 14:26:09 +01:00
shell.nix feat: add rustfmt, run nix fmt, update toolchain 2025年12月24日 14:26:09 +01:00

yourevalid

Validation type and trait. For internal use in polyproto-related crates, currently.

Overview

yourevalid provides a type-level guarantee system for validated and verified data through the Valid<T> wrapper type and the Validate trait. This crate is used in sonata and polyproto-rs.

Purpose

Many types in cryptographic and security-sensitive contexts cannot guarantee their own validity. For example, a certificate might be well-formed but expired. yourevalid provides a way to explicitly distinguish between "a value of type T" and "a value of type T that has been verified and validated."

Core Concepts

The Valid<T> Type

Look, it's you! 🏳️‍🌈🏳️‍⚧️❤️

Valid<T> is a wrapper type that signals that the contained type T has been successfully verified and validated. New instances of this type can only be created through the Validate trait, ensuring that the validation logic has been executed.

Defining "Verified and Valid"

Wow, it's you again! 🏳️‍🌈🏳️‍⚧️❤️

  • "Verified" means "Verified to be well-formed". A type that is verified must exhibit all the acceptance criteria and none of the rejection criteria according to its specification or documentation.

  • "Valid" means that, at a given point in time, one can attest that this specific instance of a type is cryptographically and contextually fit/allowed to make the claims that this instance is making. Most importantly, validity is time-sensitive and has only been attested to for a specific point in time. It must be carefully evaluated whether re-validation is necessary to maintain those guarantees if the instance is used to validate information from a different point in time.

Time-Sensitive Validation

Each Valid<T> instance tracks the exact time at which validation was performed (validated_at()). This is done because validity can change over time (e.g. a certificate can be revoked, or a time-bound credential can expire).

Example Use Case

ID-Certs have a lifetime from not_valid_before to not_valid_after. Additionally, ID-Certs can be manually revoked or invalidated. This means that the well-formedness of an ID-Cert says nothing about whether it is valid at a certain point in time. The Valid<T> type helps establish that the validity of a specific ID-Cert has been verified at a certain point in time.

Usage

Implement the Validate trait on types where validity is not a guaranteed property:

useyourevalid::{Valid,Validate};usechrono::{DateTime,Utc};#[derive(Debug)]struct MyCertificate{// data...
}implValidate<MyCertificate>forMyCertificate{type Error=MyValidationError;// Use the default validate() implementation and provide
// your validation logic as a closure/function
}// Later, validate an instance:
letcert=MyCertificate{/* ... */};letvalid_cert: Valid<MyCertificate>=MyCertificate::validate(Some(&db_pool),cert,Utc::now(),|db,cert,time|{// Your validation logic here
Ok(())}).await?;// Access the validation timestamp
letvalidated_at=valid_cert.validated_at();

License

MPL-2.0

🏳️‍⚧️ Trans rights are human rights. Be gay, do crime!