Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.snakeToCamelfunctioneffect/SchemaTransformation.ts:466
(): Transformation<string, string>

Transforms strings by converting snake_case to camelCase on decode and camelCase to snake_case on encode.

When to use

Use when you need a schema transformation to convert API field names between snake_case and camelCase conventions.

Details

Decoding converts values such as "my_field_name" to "myFieldName". Encoding converts values such as "myFieldName" back to "my_field_name". The transformation is round-trippable for standard snake_case and camelCase.

Example (Converting snake case to camel case)

import { Schema, SchemaTransformation } from "effect"

const SnakeToCamel = Schema.String.pipe(
  Schema.decode(SchemaTransformation.snakeToCamel())
)
String transformationstrimtoLowerCase
export function snakeToCamel(): Transformation<string, string> {
  return new Transformation(
    SchemaGetter.snakeToCamel(),
    SchemaGetter.camelToSnake()
  )
}