Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.stringFromBase64Stringconsteffect/SchemaTransformation.ts:1478
Transformation<string, string, never, never>

Decodes a Base64-encoded string into a UTF-8 string and encodes a UTF-8 string back to a Base64 string.

When to use

Use when you need a schema transformation for text data transmitted as Base64 strings.

Details

Decoding parses the Base64 string into a UTF-8 string. Encoding writes the string as a Base64 string.

Example (Converting Base64 to a string)

import { Schema, SchemaTransformation } from "effect"

const schema = Schema.String.pipe(
  Schema.decodeTo(Schema.String, SchemaTransformation.stringFromBase64String)
)
export const stringFromBase64String: Transformation<string, string> = new Transformation(
  SchemaGetter.decodeBase64String(),
  SchemaGetter.encodeBase64()
)
Referenced by 1 symbols