0.13.0 • Published 10 months ago
effect-schema-class v0.13.0
effect-schema-class
The power of @effect/schema and classes combined!
Example
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)
0.11.0
10 months ago
0.10.1
10 months ago
0.12.0
10 months ago
0.10.2
10 months ago
0.13.0
10 months ago
0.10.0
10 months ago
0.9.0
10 months ago
0.8.0
10 months ago
0.5.0
11 months ago
0.7.0
10 months ago
0.6.1
10 months ago
0.6.0
10 months ago
0.3.0
12 months ago
0.2.3
1 year ago
0.4.0
12 months ago
0.2.4
1 year ago
0.2.2
1 year ago
0.2.1
1 year ago
0.2.0
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago