Expand description
Declarative field normalization and validation for pactum contracts.
This crate is IO-free. Hosts and codecs call Normalize and Validate around
serialization; they do not live here.
Macros§
- define_
rule - Define composable, schema-aware normalizer + check pipelines. Define composable, schema-aware normalizer + validation pipelines.
Structs§
- Civil
Date - Calendar date without a time zone.
- Command
Spec - Discoverable command: name, reply type, fields, and invariants.
- Dial
Plan - Dial-plan entry for a locale (ISO 3166-1 alpha-2).
- Field
Issue - One field (or whole-model) invariant that failed.
- Field
Schema - One field on a struct or enum variant.
- Invariant
Spec - One check or constraint the host may discover. Enforcement still runs in Rust.
- Model
Schema - Static description of a model for the contract catalog and IDL.
- Validation
Context - Pure context passed into
validate_withso time-based checks stay deterministic. - Variant
Schema - One variant on a non-command enum (events, server frames, replies).
Enums§
Constants§
Traits§
- Check
Outcome - Result types supported by arbitrary
#[check(with = ...)]functions and closures. - Clamp
Num - Type-aware clamp supporting signed/unsigned integers and floats without lossy casts.
- Describe
Model - Emit static schema for the catalog and IDL.
- Normalize
- Mutate a value into canonical form before checks.
- Numeric
Value - Type-aware numeric validation across integers and floating-point numbers.
- Validate
- Run field rules and cross-field constraints.
Functions§
- alphanumeric
- ascii
- bool_
is_ true - check_
charset - Validate every character against a compact ASCII class spec such as
"a-z0-9_-". - check_
email - Structural email check: local@domain with a dotted domain and no control characters.
- check_
phone_ e164 - Strict E.164: leading
+, 7..=15 digits after the plus. - check_
phone_ locale - Locale-aware phone: E.164 whose country code and national length match the dial plan.
- check_
rfc3339 - RFC 3339 timestamp:
YYYY-MM-DDTHH:MM:SS+ optional.frac+Zor±HH:MM. - check_
slug - Lowercase ASCII slug:
[a-z0-9]segments joined by single-characters. - check_
url - Structural URL check (
http://orhttps://, non-empty host, no whitespace/control chars). - check_
uuid - Canonical lowercase/uppercase hyphenated UUID (
8-4-4-4-12hex digits). - check_
ymd - Parse
YYYY-MM-DD. - clamp_
f64 - clamp_
i64 - constraint_
issue - Helper used by generated constraint code.
- dial_
plan - digits
- ends_
with - finite_
f64 - list_
len - list_
unique - list_
unique_ strings - lowercase
- non_
empty - non_
negative_ i64 - number_
f64 - number_
i64 - one_of
- positive_
i64 - prefix_
nested - starts_
with - string_
len - strip_
whitespace - timestamp_
ms - trim
- uppercase
Attribute Macros§
- pactum_
rule - Mark a pure function as a reusable field rule (
#[check(rule = …)]). Mark a pure function as a reusable field rule (#[check(rule = name)]).
Derive Macros§
- Model
- Derive
Normalize,Validate, andDescribeModelfrom#[norm]/#[check]/#[constraint]. DeriveNormalize,Validate, andDescribeModelfrom#[norm]/#[check]/#[constraint]. - Pactum
Model - Alias for
Modelwhen disambiguation is preferred. Alias forModelwhen disambiguation is preferred.