Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tim-smart/effect-schema-class
https://github.com/tim-smart/effect-schema-class
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tim-smart/effect-schema-class
- Owner: tim-smart
- License: mit
- Created: 2023-04-30T21:18:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-09T21:06:37.000Z (over 1 year ago)
- Last Synced: 2024-10-19T12:32:53.746Z (22 days ago)
- Language: TypeScript
- Size: 672 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# effect-schema-class - Depreciated
## @effect/schema now has classes
The power of @effect/schema and classes combined!
## Example
```ts
import * as S from "@effect/schema/Schema"
import { SchemaClass, SchemaClassExtends } from "effect-schema-class"class Person extends SchemaClass({
id: S.number,
name: S.string,
}) {
get upperName() {
return this.name.toUpperCase()
}
}class PersonWithAge extends SchemaClassExtends(Person, {
age: S.number,
}) {
get isAdult() {
return this.age >= 18
}
}const person = new Person({ id: 1, name: "Tim" }) // constructors validate the props
const parsePerson = S.parse(Person.schema())assert(person instanceof Data.Class) // extends Data for equality checks
// clone a instance and validate the props
const john = person.copyWith({ name: "John" })assert(john.id === 1)
```## License
The MIT License (MIT)