0.13.0 • Published 2 years ago

effect-schema-class v0.13.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

2 years ago

0.10.1

2 years ago

0.12.0

2 years ago

0.10.2

2 years ago

0.13.0

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.5.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.3.0

2 years ago

0.2.3

2 years ago

0.4.0

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago