Files
reffuse/packages/example/src/domain/Todo.ts
Julien Valverdé 861e462ebd
All checks were successful
Lint / lint (push) Successful in 13s
Todos example work
2025-05-18 13:52:39 +02:00

21 lines
536 B
TypeScript

import { ThSchema } from "@thilawyn/thilaschema"
import { Schema } from "effect"
export class Todo extends Schema.Class<Todo>("Todo")({
_tag: Schema.tag("Todo"),
id: Schema.String,
content: Schema.String,
completedAt: Schema.OptionFromSelf(Schema.DateTimeUtcFromSelf),
}) {}
export const TodoFromJsonStruct = Schema.Struct({
...Todo.fields,
completedAt: Schema.Option(Schema.DateTimeUtc),
}).pipe(
ThSchema.assertEncodedJsonifiable
)
export const TodoFromJson = Schema.compose(TodoFromJsonStruct, Todo)