Skip to content

On the fly value objects in Rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

ronlobo/constrained_type

Constrained Type

On the fly value objects in Rust

crates.io Documentation Version MIT or Apache 2.0 licensed Dependency Status
build status Coverage Status downloads

This is a simple project to help create on the fly value objects aka constrained types.

It provides some helper functions to construct these from Rust primitives and turn them into domain primitives, new types, value objects, you name it.

Motivation

Constrained types guarantee valid state and behaviour from dynamic runtime inputs after construction.

This can be useful when creating simple wrapper types, so called newtypes, value objects or domain primitives.

If an input does not meet the validation criteria, it returns an error result instead.

The goal is to remove defensive code statements, ease implementing business invariants and guarantee correct state at runtime.

Heavily inspired by "Domain Modelling Made Functional".

For more complex types, please take a look at the various builder crates.

About

On the fly value objects in Rust.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages