Liking cljdoc? Tell your friends :D

rop.core

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
raw docstring

=merge-params=clj/s

(=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.
sourceraw docstring

=validate-request=clj/s

(=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 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 arequestthat holds the input data
  • input a ROP 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 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
sourceraw docstring

>>=clj/s

(>>= 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.
sourceraw docstring

>>=*clj/s

(>>=* 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.
sourceraw docstring

deadclj/s

A shortcut for calling (rop/switch (rop/tee send-email!)

A shortcut for calling (rop/switch (rop/tee send-email!)
sourceraw docstring

failclj/s

Convert a value into a two-track (failure) result

Convert a value into a two-track (failure) result
sourceraw docstring

failure?clj/s

Returns true if the given two-track value is a failure

Returns true if the given two-track value is a failure
sourceraw docstring

succeedclj/s

Convert a value into a two-track (success) result

Convert a value into a two-track (success) result
sourceraw docstring

success?clj/s

Returns true if the given two-track value is a success

Returns true if the given two-track value is a success
sourceraw docstring

switchclj/s

(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)
sourceraw docstring

teeclj/s

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close