clj-r2dbc.impl.validate
Boundary validation for clj-r2dbc public entry points.
All functions are pure: no side effects, no Missionary scheduling, and no
dependency on concrete R2DBC runtime values. Each function throws ex-info on
failure using the stable public error contract:
{:clj-r2dbc/error <category-keyword>
:clj-r2dbc/context <operation-keyword>
...operation-specific keys...}
This namespace is an implementation detail; do not use from application code.batch-opts
(batch-opts opts)
Validate and normalize opts for clj-r2dbc/batch.
Args:
opts - raw options map from the caller.
Returns the validated opts map unchanged.
check-mode!
(check-mode! opts)(check-mode! opts context)
Throw ex-info when both :middleware and :interceptors are supplied.
Exactly one execution mode may be active per call.
Args:
opts - options map to check.
context - (optional) keyword used as :clj-r2dbc/context; defaults to
:clj-r2dbc/execute.
Throws (synchronously):
ex-info :clj-r2dbc/unsupported when both :middleware and :interceptors are present.execute-each-opts
(execute-each-opts opts)
Validate and normalize opts for clj-r2dbc/execute-each.
Checks execute-each-specific keys in addition to common query opts.
Args:
opts - raw options map from the caller.
Returns the validated opts map unchanged.
execute-opts
(execute-opts opts context)
Validate and normalize opts for clj-r2dbc/execute.
Delegates to validate-common-query-opts! and checks execute-specific keys.
Args:
opts - raw options map from the caller.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Returns the validated opts map unchanged.
reject-key!
(reject-key! opts k context message)
Throw ex-info when opts contains k.
Used to reject removed or renamed public keys.
Args:
opts - options map to check.
k - key to reject.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
message - error message string.
Throws (synchronously):
ex-info :clj-r2dbc/unsupported when k is present in opts.
require-fn!
(require-fn! opts k context)
Throw ex-info if k is present in opts but its value is not a function.
require-fn-val!
(require-fn-val! v name context)
Throw ex-info when v is not a function.
Args:
v - value to check.
name - parameter name used in the error message.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/invalid-type when v is not a fn.
require-int-range!
(require-int-range! opts k min-value max-value context)
Throw ex-info when key k is present in opts but not an integer within [min max].
Args:
opts - options map to check.
k - key whose value to validate.
min-value - minimum allowed integer value (inclusive).
max-value - maximum allowed integer value (inclusive).
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/invalid-type when the value is not an integer.
ex-info :clj-r2dbc/invalid-value when the value is outside [min max].
require-keyword-in!
(require-keyword-in! opts k allowed context)
Throw ex-info when key k is present in opts but not one of allowed values.
Args:
opts - options map to check.
k - key whose value to validate.
allowed - set of allowed keyword values.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/invalid-value when the value is not in allowed.
require-map!
(require-map! v name context)
Throw ex-info when v is not a map.
Args:
v - value to check.
name - parameter name used in the error message.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/invalid-type when v is not a map.
require-non-blank-string!
(require-non-blank-string! v name context)
Throw ex-info when v is not a non-blank string.
Args:
v - value to check.
name - parameter name used in the error message.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/missing-key when v is nil.
ex-info :clj-r2dbc/invalid-type when v is not a string.
ex-info :clj-r2dbc/invalid-value when v is blank.
require-non-nil!
(require-non-nil! v name context)
Throw ex-info when v is nil.
Args:
v - value to check.
name - parameter name used in the error message.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/missing-key when v is nil.
require-sequential!
(require-sequential! opts k context)
Throw ex-info if k is present in opts but its value is not sequential.
require-sequential-val!
(require-sequential-val! v name context)
Throw ex-info when v is not sequential.
Args:
v - value to check.
name - parameter name used in the error message.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Throws (synchronously):
ex-info :clj-r2dbc/invalid-type when v is not sequential.
require-string!
(require-string! opts k context)
Throw ex-info if k is absent from opts or its value is not a non-blank string.
stream-opts
(stream-opts opts)
Validate and normalize opts for clj-r2dbc/stream.
Checks stream-specific keys in addition to common query opts.
Args:
opts - raw options map from the caller.
Returns the validated opts map unchanged.
validate-common-query-opts!
(validate-common-query-opts! opts context)
Validate opts keys common to execute, first-row, stream, and execute-each.
Checks :params, :fetch-size, :builder, :middleware, and :interceptors.
Throws ex-info for any invalid value.
Args:
opts - map of caller-supplied options.
context - keyword used as :clj-r2dbc/context in thrown ex-info.
Returns the normalized opts map (with :builder renamed to :builder-fn).