Users can bind this to a custom function, e.g. a ring handler for 400 error responses.
Users can bind this to a custom function, e.g. a ring handler for 400 error responses.
If *strip-unknown-keys* is truthy (default), unknown keys are
silently dropped. This prevents interning or processing any
unwanted input.
If *strip-unknown-keys* is falsey, unknown keys are kept in the
map, but are left as strings. This enables closed schemas to fail
validation, while still avoiding interning arbitrary user input.
If `*strip-unknown-keys*` is truthy (default), unknown keys are silently dropped. This prevents interning or processing any unwanted input. If `*strip-unknown-keys*` is falsey, unknown keys are kept in the map, but are left as strings. This enables closed schemas to fail validation, while still avoiding interning arbitrary user input.
(format-schema-error details)Format a structured error response as a simple string, for handlers which do not support structured logging.
Format a structured error response as a simple string, for handlers which do not support structured logging.
(with-schema schema request & body)Convenience wrapper for with-schemas when only validating :params.
Usage: (with-schema schema/LoginRequest request (handler request))
Convenience wrapper for `with-schemas` when only validating `:params`.
Usage:
(with-schema schema/LoginRequest request
(handler request))(with-schemas schema-map request & body)Coerces and validates multiple request maps against their respective schemas.
Accepts a map of request keys to schemas (e.g., {:params LoginRequest, :path-params UserPath}).
On success: Merges coerced maps back into the request and executes body.
On failure: Short-circuits on the first failure and returns a 400 Bad Request via
bad-request-response. Includes an :in key in the error details indicating which
request key failed validation.
Uses the dynamic variables bad-request-handler to format 400 responses strip-unknown-keys to control behavior for unknown keys
Usage: (with-schemas {:params schema/LoginRequest :path-params schema/UserPath} request (handler request))
Coerces and validates multiple request maps against their respective schemas.
Accepts a map of request keys to schemas (e.g., {:params LoginRequest, :path-params UserPath}).
On success: Merges coerced maps back into the request and executes body.
On failure: Short-circuits on the first failure and returns a 400 Bad Request via
bad-request-response. Includes an `:in` key in the error details indicating which
request key failed validation.
Uses the dynamic variables
*bad-request-handler* to format 400 responses
*strip-unknown-keys* to control behavior for unknown keys
Usage:
(with-schemas {:params schema/LoginRequest
:path-params schema/UserPath}
request
(handler request))cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |