# greyblake/nutype

Rust newtype with guarantees  🇺🇦 🦀

Repository: https://github.com/greyblake/nutype
Canonical: https://ross.abutalabs.com/products/nutype
Language: Rust
License: MIT
License Family: permissive
Topics: data, data-structures, macro, macros, newtype, rust, rust-lang, rust-library, sanitization, sanitizer, typesafety, validation, validator, web, invariant, invariants, invariance
Last push: 2026-06-18T08:34:45+00:00

## Health v2 (maintenance only)
Score: 80/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 88, release rhythm 57, longevity 100
- inputs: {"age_days": 1424, "days_push": 76, "days_rel": 130, "gap_med": 108, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1761, forks 34 (observed 2026-08-28T04:05:32.723988+00:00)

## What it is
Nutype is a Rust procedural macro that enhances the newtype pattern with built-in sanitization and validation constraints. It guarantees that values cannot be instantiated without passing the defined checks, including during serde deserialization.

## Use cases
- validate user input like usernames and emails in Rust
- enforce invariants on newtype wrappers
- sanitize and trim strings before storing them
- make invalid states unrepresentable with types
- validate data during serde deserialization
- define constrained numeric types with min/max bounds

## When to choose
- you use Rust and want type-safe validated domain types
- you want validation enforced at construction time rather than scattered checks
- you need sanitization plus validation in one declarative macro
- you want invalid values rejected even through serde deserialization

## When to avoid
- you need runtime-configurable validation rules
- your project is not in Rust
- you need validation across struct fields rather than single values
- you prefer schema-based validation libraries like validator with attribute macros on structs

## Facets
- artifact type: library
- maturity: active
- function: serialization, type-system, developer-tools
- domain: developer-tools, web-development, programming-languages
- platform: rust
- tags: newtype, validation, sanitization, proc-macro, invariants, type-safety, serde

## Member repositories
- greyblake/nutype (main) score 80

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:32.723988+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:27:11.435373+00:00, confidence not recorded.
  - readme: https://github.com/greyblake/nutype (fetched 2026-08-28T04:05:32.723988+00:00, sha 9db641755a2f)
  - registry_crates: https://crates.io/api/v1/crates/nutype (fetched 2026-08-29T11:05:24.677598+00:00, sha e88c8238c86f)
- Data as of 2026-08-30T08:39:29.467469+00:00.
