Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.uncapitalizefunctioneffect/SchemaTransformation.ts:614
(): Transformation<string, string>

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

When to use

Use when you need a schema transformation to normalize identifiers or field names.

Details

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

Example (Uncapitalizing on decode)

import { Schema, SchemaTransformation } from "effect"

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