Files
effect/bundle/schema-string-async.ts
T
Giulio Canti f5b26b2feb annotate as pipe-able function (#117)
* Refactor schema annotation method to use pipe syntax for consistency across schema operations

* renaming

* rename SchemaValidator to SchemaParser

* move make from schemas to SchemaParser

* fix bundle imports

* rename serialization annotation

* simplify makeClass impl
2025-05-12 10:39:35 +02:00

21 lines
663 B
TypeScript

import * as Effect from "#dist/effect/Effect"
import * as Option from "#dist/effect/Option"
import * as Result from "#dist/effect/Result"
import * as Schema from "#dist/effect/Schema"
import * as SchemaParser from "#dist/effect/SchemaParser"
import * as SchemaTransformation from "#dist/effect/SchemaTransformation"
const schema = Schema.String.pipe(Schema.decodeTo(
Schema.String,
SchemaTransformation.transformOrFail(
(s) =>
Effect.gen(function*() {
yield* Effect.sleep(300)
return Option.some(s)
}),
(s) => Result.succeedSome(s)
)
))
SchemaParser.decodeUnknown(schema)("a").pipe(Effect.runPromise).then(console.log)