asobi_jsonb (asobi v0.72.5)

View Source

Size-bound checks for values headed into an unbounded jsonb column.

A jsonb column has no server-side size limit of its own, so any field a client can populate through a changeset cast is a lever for an oversized payload unless something checks it first (asobi#169, asobi#216). This is the one place that idiom lives, shared by every schema and controller that needs it rather than a per-call-site copy.

Summary

Functions

check(Value, MaxBytes)

-spec check(dynamic(), non_neg_integer()) -> ok | too_large | not_encodable.

default_metadata_bytes()

-spec default_metadata_bytes() -> non_neg_integer().

within_limit(Value, MaxBytes)

-spec within_limit(dynamic(), non_neg_integer()) -> boolean().