Data & codecs7 exports
Raw Markdown/validation
Declarative Struct field constraint validation (#{:min-len ... :format :email ...}) returning ValidationErrors.
Structs#
Functions & symbols#
Validation#
function
Validation outcome Struct returned by `(validation/validate x)`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
ok | Bool | required | Overall validation success flag |
errors | Map | required | Map of {:field [error-messages...]} |
Returns:
Any(let res (Validation true {}))ValidationErrors#
function
Form/validation error container Struct pairing field errors with submitted input values.
| Parameter | Type | Optional | Description |
|---|---|---|---|
errors | Map | required | Field error arrays keyed by field KeySymbol |
values | Map | optional | Submitted raw input values |
Returns:
Any(ValidationErrors {:email ["Invalid email"]})get-cached-descriptor#
function
Looks up the precompiled native validation descriptor for `struct-type`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
struct_type | Type | Struct | required | Struct definition or name |
Returns:
Any(validation/get-cached-descriptor User)is-valid?#
function
Returns `true` if `instance` satisfies every field constraint.
| Parameter | Type | Optional | Description |
|---|---|---|---|
instance | Any | required | Struct instance or Map |
schema | Struct | Map | optional | Optional target Struct descriptor |
Returns:
Any(assert! (validation/is-valid? user))validate#
function
Validates all field constraints on `instance` and returns a `Validation` struct `{:ok Bool :errors {:field ["msg" ...]}}`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
instance | Any | required | Struct instance or Map to validate |
schema | Struct | Map | optional | Optional target Struct descriptor when validating raw Maps |
Returns:
Any(let v (validation/validate signup-form))