Implementation of Railway Oriented Programming based on https://gist.github.com/ah45/7518292c620679c460557a7038751d6d
Implementation of Railway Oriented Programming based on https://gist.github.com/ah45/7518292c620679c460557a7038751d6d
(=merge-params= source target {:keys [request] :as input})
A railway function that merges a given source
key into a target
key in a request.
It's useful when route params and body params are validated together.
A railway function that merges a given `source` key into a `target` key in a request. It's useful when route params and body params are validated together.
(=validate-request= validate
scheme
defaults
request-key
{:keys [request] :as input})
A railway function that validates a request by a given scheme. If data are valid it updates them in the request (with coerced data), otherwise returns Bad Requests within errors.
Parameters:
validate
a function that takes an input and a validation scheme, it should return a tuple of errors
and validated inputscheme
a validation schemedefault
default values as a hash-map
, it will be merged into a validated inputrequest-key a key in a
requestthat holds the input data
input
a ROP inputA railway function that validates a request by a given scheme. If data are valid it updates them in the request (with coerced data), otherwise returns Bad Requests within errors. Parameters: - `validate` a function that takes an input and a validation scheme, it should return a tuple of errors and validated input - `scheme` a validation scheme - `default` default values as a `hash-map`, it will be merged into a validated input - `request-key a key in a `request` that holds the input data` - `input` a ROP input
(>>= input & fns)
An infix version of bind for piping two-track values into switch fns. Can be used to pipe two-track values through a series of switch fns. First is an input hash-map it will be passed throgh switch fns. Rest parameters as switch fns.
An infix version of bind for piping two-track values into switch fns. Can be used to pipe two-track values through a series of switch fns. First is an input hash-map it will be passed throgh switch fns. Rest parameters as switch fns.
(>>=* success-key-or-tuple input & fns)
An infix version of bind for piping two-track values into switch fns. Can be used to pipe two-track values
through a series of switch fns. A result of this function is Ring's response.
First parameter is a success key (it will be used as :body in result hash-map) or a tuple with success-key and
output-keys (at the end select-keys
will be applied on a success result with these output-keys
).
Second is an input hash-map it will be passed throgh switch fns. Rest parameters as switch fns.
An infix version of bind for piping two-track values into switch fns. Can be used to pipe two-track values through a series of switch fns. A result of this function is Ring's response. First parameter is a success key (it will be used as :body in result hash-map) or a tuple with success-key and output-keys (at the end `select-keys` will be applied on a success result with these `output-keys`). Second is an input hash-map it will be passed throgh switch fns. Rest parameters as switch fns.
A shortcut for calling (rop/switch (rop/tee send-email!)
A shortcut for calling (rop/switch (rop/tee send-email!)
Convert a value into a two-track (failure) result
Convert a value into a two-track (failure) result
Returns true if the given two-track value is a failure
Returns true if the given two-track value is a failure
Convert a value into a two-track (success) result
Convert a value into a two-track (success) result
Returns true if the given two-track value is a success
Returns true if the given two-track value is a success
(switch f)
Converts a normal fn into a switch (one-track input, two-track output)
Converts a normal fn into a switch (one-track input, two-track output)
(tee f)
Returns a fn that calls f on its argument and returns its argument. Converts otherwise 'dead-end' fns into one-track fns.
Returns a fn that calls f on its argument and returns its argument. Converts otherwise 'dead-end' fns into one-track fns.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close