Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.capitalizefunctioneffect/SchemaTransformation.ts:577
(): Transformation<string, string>

Transforms strings by capitalizing the first character on decode. Encode is passthrough.

When to use

Use when you need a schema transformation to normalize display names or titles.

Details

Decoding uppercases the first character and leaves the rest unchanged. Encoding is passthrough.

Example (Capitalizing on decode)

import { Schema, SchemaTransformation } from "effect"

const Capitalized = Schema.String.pipe(
  Schema.decode(SchemaTransformation.capitalize())
)
String transformationsuncapitalizetoUpperCase
export function capitalize(): Transformation<string, string> {
  return new Transformation(
    SchemaGetter.capitalize(),
    SchemaGetter.passthrough()
  )
}