effect-config-schema

- Validating request bodies, params, or external inputs

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "effect-config-schema" with this command: npx skills add mepuka/effect-ontology/mepuka-effect-ontology-effect-config-schema

Config & Schema

When to use

  • Validating request bodies, params, or external inputs

  • Loading environment configuration with types

Config (example)

import { Config } from "effect"

const Server = Config.nested("SERVER")(Config.all({ host: Config.string("HOST"), port: Config.number("PORT") }))

Schema Validate

import { Schema as S } from "effect"

const User = S.Struct({ id: S.Number, name: S.String }) const decodeUser = (u: unknown) => S.decodeUnknown(User)(u)

Transform

const IsoDate = S.String // then transform to Date in pipeline where needed

Real-world snippet: Layer selecting AWS credentials via Config options

class AwsCredentials extends Effect.Service<AwsCredentials>()("AwsCredentials", { effect: Effect.gen(function* () { const accessKeys = yield* Config.option( Config.all([Config.string("CAP_AWS_ACCESS_KEY"), Config.string("CAP_AWS_SECRET_KEY")]) ) const vercelAwsRole = yield* Config.option(Config.string("VERCEL_AWS_ROLE_ARN"))

const credentials = yield* Effect.gen(function* () {
  if (Option.isSome(vercelAwsRole)) return awsCredentialsProvider({ roleArn: vercelAwsRole.value })
  if (Option.isSome(accessKeys)) {
    const [accessKeyId, secretAccessKey] = accessKeys.value
    return { accessKeyId, secretAccessKey }
  }
  return fromContainerMetadata()
})

return { credentials }

}) })

Guidance

  • Prefer schemas close to boundaries; keep core logic typed

  • For branded types (Email, PositiveInt), use transform/brand helpers

  • Validate early, map to domain errors in one place

Pitfalls

  • Accepting unknown into core → always decode first

  • Large ad-hoc validation code → centralize in Schema

Cross-links

  • HTTP & Routing for endpoint validation

  • Foundations for operator style

Local Source Reference

CRITICAL: Search local Effect source before implementing

The full Effect source code is available at docs/effect-source/ . Always search the actual implementation before writing Effect code.

Key Source Files

  • Config: docs/effect-source/effect/src/Config.ts

  • Schema: docs/effect-source/schema/src/Schema.ts

Example Searches

Find Config patterns and options

grep -F "Config.string" docs/effect-source/effect/src/Config.ts grep -F "Config.number" docs/effect-source/effect/src/Config.ts grep -F "Config.option" docs/effect-source/effect/src/Config.ts

Study Schema validation

grep -F "Struct" docs/effect-source/schema/src/Schema.ts grep -F "decodeUnknown" docs/effect-source/schema/src/Schema.ts

Find Schema transforms

grep -rF "transform" docs/effect-source/schema/src/ grep -rF "brand" docs/effect-source/schema/src/

Look at Config test examples

grep -F "Config." docs/effect-source/effect/test/Config.test.ts

Workflow

  • Identify the Config or Schema API you need

  • Search docs/effect-source/effect/src/Config.ts or docs/effect-source/schema/src/Schema.ts

  • Study the types and validation patterns

  • Look at test files for usage examples

  • Write your code based on real implementations

Real source code > documentation > assumptions

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

effect-index

No summary provided by upstream source.

Repository SourceNeeds Review
299-mepuka
General

effect-patterns-hub

No summary provided by upstream source.

Repository SourceNeeds Review
General

effect-concurrency-fibers

No summary provided by upstream source.

Repository SourceNeeds Review
General

effect-errors-retries

No summary provided by upstream source.

Repository SourceNeeds Review