This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

effect-schema-class
TypeScript icon, indicating that this package has built-in type declarations

0.13.0 • Public • Published

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)

Readme

Keywords

none

Package Sidebar

Install

npm i effect-schema-class

Weekly Downloads

8

Version

0.13.0

License

MIT

Unpacked Size

38.3 kB

Total Files

16

Last publish

Collaborators

  • tim-smart