Using Schema.omit disables filters silently - Bug or Intended?
Why does using Schema.omit disable all the filters silently? Is this a bug or its intended?
Here is reproducable example: https://effect.website/play/#7450d5e1c857
Here is reproducable example: https://effect.website/play/#7450d5e1c857
import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, HttpApiSwagger } from "@effect/platform"
import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
import { Effect, Layer, Schema } from "effect"
import { createServer } from "node:http"
const PostSchema = Schema.Struct({
id: Schema.String,
name: Schema.String
}).pipe(
Schema.filter(
(s) => {
if (s.name === "test") {
return "Test name is not allowed"
}
return true
},
{
description: "Test name is not allowed",
jsonSchema: {}
}
)
)
const CreatePostSchema = PostSchema.pipe(
Schema.omit("id")
)
const MyApi = HttpApi.make("MyApi").add(
HttpApiGroup.make("Greetings").add(
HttpApiEndpoint.post("post-greeting", "/")
.addSuccess(CreatePostSchema)
.setPayload(CreatePostSchema)
)
)
const GreetingsLive = HttpApiBuilder.group(
MyApi,
"Greetings",
(handlers) =>
handlers.handle("post-greeting", ({ payload }) =>
Effect.gen(function*() {
console.log(payload)
return payload
}))
)
const MyApiLive = HttpApiBuilder.api(MyApi).pipe(Layer.provide(GreetingsLive))
const ServerLive = HttpApiBuilder.serve().pipe(
Layer.provide(HttpApiSwagger.layer()),
Layer.provide(MyApiLive),
Layer.provide(NodeHttpServer.layer(createServer, { port: 3003 }))
)
Layer.launch(ServerLive).pipe(NodeRuntime.runMain)import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, HttpApiSwagger } from "@effect/platform"
import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
import { Effect, Layer, Schema } from "effect"
import { createServer } from "node:http"
const PostSchema = Schema.Struct({
id: Schema.String,
name: Schema.String
}).pipe(
Schema.filter(
(s) => {
if (s.name === "test") {
return "Test name is not allowed"
}
return true
},
{
description: "Test name is not allowed",
jsonSchema: {}
}
)
)
const CreatePostSchema = PostSchema.pipe(
Schema.omit("id")
)
const MyApi = HttpApi.make("MyApi").add(
HttpApiGroup.make("Greetings").add(
HttpApiEndpoint.post("post-greeting", "/")
.addSuccess(CreatePostSchema)
.setPayload(CreatePostSchema)
)
)
const GreetingsLive = HttpApiBuilder.group(
MyApi,
"Greetings",
(handlers) =>
handlers.handle("post-greeting", ({ payload }) =>
Effect.gen(function*() {
console.log(payload)
return payload
}))
)
const MyApiLive = HttpApiBuilder.api(MyApi).pipe(Layer.provide(GreetingsLive))
const ServerLive = HttpApiBuilder.serve().pipe(
Layer.provide(HttpApiSwagger.layer()),
Layer.provide(MyApiLive),
Layer.provide(NodeHttpServer.layer(createServer, { port: 3003 }))
)
Layer.launch(ServerLive).pipe(NodeRuntime.runMain)