You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

effect-schema-class

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effect-schema-class

The power of @effect/schema and classes combined!

0.11.0
Source
npmnpm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

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)

FAQs

Package last updated on 27 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts