/web/app/forms
HTML form binding, type coercion, CSRF token fields (<csrf-field>), and field validation errors (<form-error>).
Functions & symbols#
Validation#
Re-exported Validation result struct from `/validation`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
ok | Bool | required | Overall validation success flag |
errors | Map | required | Map of {:field [error-messages...]} |
Any(let res (Validation true {}))ValidationErrors#
Re-exported ValidationErrors struct from `/validation`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
errors | Map | required | Field error arrays keyed by field KeySymbol |
values | Map | optional | Submitted raw input values |
Any(ValidationErrors {:email ["Invalid email"]})add-field-error#
Attaches a custom error message to `field` on `target` (a Struct, `ValidationErrors`, or `Map`), returning a `ValidationErrors`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
target | Any | required | — |
field | Any | required | — |
message | Any | required | — |
Anycoerce-field-value#
Coerces a raw form field value into `type-name` using the unified parameter coercion engine.
| Parameter | Type | Optional | Description |
|---|---|---|---|
raw-value | Any | required | — |
type-name | Any | required | — |
constraints | Any | required | — |
Anyextract-inner-type#
Extracts the inner type name from an optional `(Maybe T)` or `(Or T)` type string.
| Parameter | Type | Optional | Description |
|---|---|---|---|
type-str | Any | required | — |
Anyfirst-error-of#
Returns the first validation error message across all fields in `target`, or `()` if none exist.
| Parameter | Type | Optional | Description |
|---|---|---|---|
target | Any | required | — |
Anyflat-errors-of#
Projects `target`'s errors into a flat `{:field "first error"}` map suitable for UI components.
| Parameter | Type | Optional | Description |
|---|---|---|---|
target | Any | required | — |
Anyget-field-error#
Returns the first error message string for `field` on `target`, or `()` if valid.
| Parameter | Type | Optional | Description |
|---|---|---|---|
target | Any | required | — |
field | Any | required | — |
Anyget-field-errors#
Returns the array of error messages for `field` on `target`, or `[]` if valid.
| Parameter | Type | Optional | Description |
|---|---|---|---|
target | Any | required | — |
field | Any | required | — |
Anyget-field-value#
Looks up a field value on a Struct instance, `ValidationErrors`, or `Map`, returning `default-val` when absent.
| Parameter | Type | Optional | Description |
|---|---|---|---|
args | Any | optional | — |
Anyhas-field-error?#
Returns true if `target` has any validation error (or an error on `field` when `field` is provided).
| Parameter | Type | Optional | Description |
|---|---|---|---|
args | Any | optional | — |
Anyis-file-selected?#
Returns true if a multipart file upload map contains a non-empty filename and non-empty content.
| Parameter | Type | Optional | Description |
|---|---|---|---|
upload | Any | required | — |
Anyis-maybe-type?#
Returns true if `type-str` is an optional `(Maybe ...)` or `(Or ...)` type.
| Parameter | Type | Optional | Description |
|---|---|---|---|
type-str | Any | required | — |
Anyis-valid?#
Re-exported validation check predicate from `/validation`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
instance | Any | required | Struct instance or Map |
schema | Struct | Map | optional | Optional target Struct descriptor |
Any(assert! (validation/is-valid? user))merge-form-errors#
Merges two or more `ValidationErrors` (or ` ():` / valid targets) into a single `ValidationErrors`, or returns `()` if all are valid.
| Parameter | Type | Optional | Description |
|---|---|---|---|
targets | Any | optional | — |
Anyread-form#
Reads and coerces a request's form body into `struct-type` (re-exported from `/web/app`).
| Parameter | Type | Optional | Description |
|---|---|---|---|
req | Any | required | — |
struct-type | Any | required | — |
Anyrespond-form-errors#
Returns a 422 Unprocessable Entity response negotiated for JSON, Stage/HTML (via `render-fn`), or plain text.
| Parameter | Type | Optional | Description |
|---|---|---|---|
args | Any | optional | — |
Anyvalidate#
Re-exported struct validation function from `/validation`.
| 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 |
Any(let v (validation/validate signup-form))validate-form#
Validates a form struct instance or parses and validates `req` against `struct-type`, returning a `Validation`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
args | Any | optional | — |
Anyvalidate-upload#
Validates a multipart file upload map against `:required`, `:max-bytes`, and `:accept` rules, returning `()` or `ValidationErrors`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
upload | Any | required | — |
rest | Any | optional | — |
Any