mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-02 03:15:52 +08:00
* 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
21 lines
663 B
TypeScript
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)
|