Effect CommunityEC
Effect Community2mo ago
4 replies
Janosch

How to Enforce Complete Schema Validation in Effect TypeScript

import { Effect, Schema } from "effect"

const myFn = <A, E, R>(effect: Effect.Effect<A, E, R>, schema: Schema.Schema<A, A, never>) => {
  return 12
}

const p = Effect.gen(function*() {
  return {
    test: "123",
    value: {
      a: 12
    }
  }
}).pipe((effect) =>
  myFn(
    effect,
    Schema.Struct({
      test: Schema.String,
    })
  )
);

I wonder why I can just pass Schema.Struct({ test: Schema.String }) with a missing property. I could even pass in an empty Struct and it would work, while A should be typeof
{
    test: "123",
    value: {
      a: 12
    }
  }


Is there a type that enforces
A
entirely?
Was this page helpful?