2 unstable releases
0.2.0 | Apr 11, 2023 |
---|---|
0.1.0 | Mar 1, 2023 |
#289 in #builder
36 downloads per month
Used in 2 crates
(via valibuk_derive)
26KB
660 lines
Valibuk
Valibuk is a library and a set of macros implementing the correct-by-construction pattern.
Correct-by-construction is a pattern that leverages the type system to guard against bugs that can come from improperly validating inputs. It does so by having an "unvalidated" type and a "validated" type. The only way of obtaining an instance of the validated type is to run all the defined validations on the unvalidated type. Then the correctness is achieved by using the correct type.
A small example
See more examples in tests
and examples
.
TODO
- Move validator registrations into macro annotations
- Support fields without validating
- Add UI tests using trybuild
- Support structs with lifetime params
- Support structs with generics
- Support global validators (take the whole struct)
- Add validator combinators
Dependencies
~1.5MB
~34K SLoC