effect-io-ai

Package: effect
Module: Schema

Schema.tagDefaultOmit

Creates a literal _tag schema that is omitted from encoded output.

When to use

Use to decode data that omits the discriminator field while still constructing values with a _tag for tagged union matching.

Details

The tag is filled during decoding and construction, like tag, but is omitted when encoding.

Example (Omitting tags during encoding)

import { Schema } from "effect"

const A = Schema.Struct({
  _tag: Schema.tagDefaultOmit("A"),
  value: Schema.Number
})

// Encode strips the _tag field
const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
// encoded: { value: 1 }

See

Signature

declare const tagDefaultOmit: <Tag extends SchemaAST.LiteralValue>(literal: Tag) => withDecodingDefaultKey<tag<Tag>, never>

Source

Since v4.0.0