Piping Filters and Brands into Schema without Transform in Effect Typescript
Hi guys,
I'm wondering if there is an easy way to pipe into schema with filters and brands without transform?
I'm wondering if there is an easy way to pipe into schema with filters and brands without transform?
import { Schema } from "effect"
const SmallSerialIdSchema = Schema.Int.pipe(
Schema.positive(),
Schema.lessThanOrEqualTo(32767),
);
const EmailTemplateIdSchema = SmallSerialIdSchema.pipe(
Schema.brand("EmailTemplateId"),
);
// Piping doesn't work
// Argument of type 'brand<filter<filter<typeof Int>>, "EmailTemplateId">' is not assignable to parameter of type '(_: typeof NumberFromString) => never'.
// Type 'brand<filter<filter<typeof Int>>, "EmailTemplateId">' provides no match for the signature '(_: typeof NumberFromString): never'.(2345)
const WrongEmailTemplateParamSchema = Schema.NumberFromString.pipe(EmailTemplateIdSchema)
// But transform works
const EmailTemplateIdParamSchema = Schema.transform(
Schema.NumberFromString,
EmailTemplateIdSchema,
{
strict: true,
decode: (val) => val,
encode: (val) => val,
},
)import { Schema } from "effect"
const SmallSerialIdSchema = Schema.Int.pipe(
Schema.positive(),
Schema.lessThanOrEqualTo(32767),
);
const EmailTemplateIdSchema = SmallSerialIdSchema.pipe(
Schema.brand("EmailTemplateId"),
);
// Piping doesn't work
// Argument of type 'brand<filter<filter<typeof Int>>, "EmailTemplateId">' is not assignable to parameter of type '(_: typeof NumberFromString) => never'.
// Type 'brand<filter<filter<typeof Int>>, "EmailTemplateId">' provides no match for the signature '(_: typeof NumberFromString): never'.(2345)
const WrongEmailTemplateParamSchema = Schema.NumberFromString.pipe(EmailTemplateIdSchema)
// But transform works
const EmailTemplateIdParamSchema = Schema.transform(
Schema.NumberFromString,
EmailTemplateIdSchema,
{
strict: true,
decode: (val) => val,
encode: (val) => val,
},
)