Package: effect
Module: SchemaTransformation
Decodes a string into a bigint and encodes a bigint back to a
string.
When to use
Use when you need a schema transformation to parse large integer strings (e.g. database IDs, blockchain values).
Details
Decoding coerces the string to a bigint like BigInt(s). Encoding coerces
the bigint to a string like String(n). Decoding fails if the string is not
a valid bigint representation.
Example (Converting a string to a BigInt)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.String.pipe(
Schema.decodeTo(Schema.BigInt, SchemaTransformation.bigintFromString)
)
See
numberFromStringtransformSignature
declare const bigintFromString: Transformation<bigint, string, never, never>
Since v4.0.0