Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.toLowerCasefunctioneffect/SchemaTransformation.ts:503
(): Transformation<string, string>

Transforms strings by lowercasing on decode. Encode is passthrough.

When to use

Use when you need a schema transformation to normalize strings to lowercase (e.g. email addresses).

Details

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

Example (Lowercasing on decode)

import { Schema, SchemaTransformation } from "effect"

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