Skip to main content

Crate pactum_annotations

Crate pactum_annotations 

Source
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§

CivilDate
Calendar date without a time zone.
CommandSpec
Discoverable command: name, reply type, fields, and invariants.
DialPlan
Dial-plan entry for a locale (ISO 3166-1 alpha-2).
FieldIssue
One field (or whole-model) invariant that failed.
FieldSchema
One field on a struct or enum variant.
InvariantSpec
One check or constraint the host may discover. Enforcement still runs in Rust.
ModelSchema
Static description of a model for the contract catalog and IDL.
ValidationContext
Pure context passed into validate_with so time-based checks stay deterministic.
VariantSchema
One variant on a non-command enum (events, server frames, replies).

Enums§

LengthUnit
ModelKind

Constants§

DIAL_PLANS

Traits§

CheckOutcome
Result types supported by arbitrary #[check(with = ...)] functions and closures.
ClampNum
Type-aware clamp supporting signed/unsigned integers and floats without lossy casts.
DescribeModel
Emit static schema for the catalog and IDL.
Normalize
Mutate a value into canonical form before checks.
NumericValue
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 + Z or ±HH:MM.
check_slug
Lowercase ASCII slug: [a-z0-9] segments joined by single - characters.
check_url
Structural URL check (http:// or https://, non-empty host, no whitespace/control chars).
check_uuid
Canonical lowercase/uppercase hyphenated UUID (8-4-4-4-12 hex 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, and DescribeModel from #[norm] / #[check] / #[constraint]. Derive Normalize, Validate, and DescribeModel from #[norm] / #[check] / #[constraint].
PactumModel
Alias for Model when disambiguation is preferred. Alias for Model when disambiguation is preferred.