Liking cljdoc? Tell your friends :D

io.randomseed.bankster.serializers.common

Bankster library, shared serialization helpers.

Bankster library, shared serialization helpers.
raw docstring

extract-keys-specclj

(extract-keys-spec keys-vec)

Extracts nested opts from :keys vector.

Returns map of {field-keyword -> nested-opts-or-nil}. Returns empty map {} for empty vector (filters everything out). Returns nil for nil input (no filtering).

E.g. [:amount {:currency {:keys [:id :numeric]}}] => {:amount nil, :currency {:keys [:id :numeric]}}

Extracts nested opts from :keys vector.

Returns map of {field-keyword -> nested-opts-or-nil}.
Returns empty map {} for empty vector (filters everything out).
Returns nil for nil input (no filtering).

E.g. [:amount {:currency {:keys [:id :numeric]}}]
     => {:amount nil, :currency {:keys [:id :numeric]}}
sourceraw docstring

filter-map-by-keysclj

(filter-map-by-keys m keys-spec serializer-fn)

Filters map m to only include keys from keys-spec.

For keys with nested opts, applies those opts recursively via serializer-fn.

Filters map `m` to only include keys from `keys-spec`.

For keys with nested opts, applies those opts recursively via `serializer-fn`.
sourceraw docstring

make-moneyclj

(make-money currency amount registry)
(make-money currency amount registry rounding-mode)
(make-money currency amount registry rounding-mode rescale)

Creates Money from currency and amount for deserialization.

When rescale is provided (non-nil integer), the Currency object is cloned with that scale instead of using its nominal scale. This allows deserializing data with a different precision than the registry currency defines.

The rounding-mode can be a RoundingMode, keyword, or string - it will be parsed using scale/post-parse-rounding. If not provided, falls back to scale/*rounding-mode* or throws on precision loss.

Arguments:

  • currency - Currency object or identifier (keyword, string)
  • amount - BigDecimal amount
  • registry - Registry to use for currency lookup
  • rounding-mode - optional rounding mode (RoundingMode, keyword, or string)
  • rescale - optional target scale (overrides currency's nominal scale)
Creates Money from currency and amount for deserialization.

When `rescale` is provided (non-nil integer), the Currency object is cloned with
that scale instead of using its nominal scale. This allows deserializing data with
a different precision than the registry currency defines.

The rounding-mode can be a RoundingMode, keyword, or string - it will be parsed
using `scale/post-parse-rounding`. If not provided, falls back to
`scale/*rounding-mode*` or throws on precision loss.

Arguments:
- `currency`      - Currency object or identifier (keyword, string)
- `amount`        - BigDecimal amount
- `registry`      - Registry to use for currency lookup
- `rounding-mode` - optional rounding mode (RoundingMode, keyword, or string)
- `rescale`       - optional target scale (overrides currency's nominal scale)
sourceraw docstring

parse-bigdecclj

(parse-bigdec x op-kw)

Parses a value to BigDecimal.

Accepts:

  • nil -> nil
  • BigDecimal -> as-is
  • integer -> BigDecimal/valueOf
  • number -> BigDecimal/valueOf (note: doubles lose precision)
  • string -> parsed via bigdec (trims whitespace, removes underscores)

Throws ExceptionInfo on invalid input. The op-kw argument is used in error messages to identify the calling operation.

Parses a value to BigDecimal.

Accepts:
- nil -> nil
- BigDecimal -> as-is
- integer -> BigDecimal/valueOf
- number -> BigDecimal/valueOf (note: doubles lose precision)
- string -> parsed via `bigdec` (trims whitespace, removes underscores)

Throws ExceptionInfo on invalid input. The `op-kw` argument is used in error
messages to identify the calling operation.
sourceraw docstring

rescale-amountclj

(rescale-amount amount rescale rounding-mode)

Rescales a BigDecimal amount to the given scale for serialization.

When rescale is nil, returns the amount as-is. When rescale is provided, rescales using the given rounding-mode or falls back to scale/*rounding-mode* or UNNECESSARY.

The rounding-mode can be a RoundingMode, keyword, or string.

Rescales a BigDecimal amount to the given scale for serialization.

When `rescale` is nil, returns the amount as-is.
When `rescale` is provided, rescales using the given rounding-mode or
falls back to `scale/*rounding-mode*` or UNNECESSARY.

The rounding-mode can be a RoundingMode, keyword, or string.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close