pgrx_validation
emi_monorepo · Cross-target Rust validation library compiled as PostgreSQL functions through an optional pgrx feature.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100812 | pgrx_validation | emi_monorepo | 0.0.0 | FUNC | GPL-3.0 | Rust |
PostgreSQL · 13, 14, 15, 16, 17
Usage
Sources:
pgrx_validation exposes the EMI project’s shared validation rules as PostgreSQL functions. They are intended for database constraints that apply the same string, numeric, UUID, timestamp, and icon checks used by other application targets.
Core Workflow
The generated functions are STRICT, so a null input yields null. A PostgreSQL CHECK accepts null; use NOT NULL separately when absence must be rejected.
Validation Functions
- Strings:
must_be_email(text),must_not_be_empty(text),must_not_be_padded(text),must_not_contain_consecutive_whitespace(text),must_not_contain_control_characters(text),must_be_paragraph(text), andmust_be_distinct(text, text). - Integers and UUIDs:
must_be_positive_i16(smallint),must_be_positive_i32(int),must_be_strictly_positive_i16(smallint),must_be_strictly_positive_i32(int),must_be_distinct_i16(smallint, smallint),must_be_distinct_i32(int, int), andmust_be_distinct_uuid(uuid, uuid). - Floating point:
must_be_strictly_positive_f32(real),must_be_strictly_positive_f64(double precision), plus themust_be_greater_than_f32,must_be_smaller_than_f32,must_be_strictly_greater_than_f32,must_be_strictly_smaller_than_f32,must_be_strictly_greater_than_f64, andmust_be_strictly_smaller_than_f64bound checks. - Other checks:
must_be_smaller_than_utc(timestamptz, timestamptz),must_be_strictly_smaller_than_utc(timestamptz, timestamptz), andmust_be_font_awesome_class(text).
Operational Notes
The reviewed package version is 0.0.0 and the API may still change. The extension is non-relocatable; its control file sets superuser = true and trusted = false, so a superuser must create it. It declares no prerequisite extension or preload requirement. Treat these predicates as application validation, not security sanitization, and regression-test constraints when upgrading the shared rules.