Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.toUpperCasefunctioneffect/SchemaTransformation.ts:540
(): Transformation<string, string>

Transforms strings by uppercasing on decode. Encode is passthrough.

When to use

Use when you need a schema transformation to normalize strings to uppercase (e.g. country codes).

Details

Decoding applies String.prototype.toUpperCase(). Encoding is passthrough. This is not round-trippable if the original had lowercase characters.

Example (Uppercasing on decode)

import { Schema, SchemaTransformation } from "effect"

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