Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.bigintFromStringconsteffect/SchemaTransformation.ts:845
Transformation<bigint, string, never, never>

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)
)
export const bigintFromString = new Transformation(
  SchemaGetter.BigInt(),
  SchemaGetter.String()
)
Referenced by 1 symbols