Packages

sealed trait Schema[A] extends AnyRef

A Schema[A] describes the structure of some data type A, in terms of case classes, enumerations (sealed traits), collections, and various primitive types (including not only Scala's own primitive types, but enhanced with java.time and big integers / decimals).

Schemas models the structure of data types as first class values, so they can be introspected, transformed, and combined using ordinary Scala code, without macros, metaprogramming, or codegen.

There are implicit schemas provided for all standard Scala types, and you can automatically derive schemas for your own data types by using DeriveSchema.gen[A]. Whether you write them by hand by using constructors and operators,

final case class Person(name: String, age: Int)
object Person {
  implicit val personSchema: Schema[Person] = DeriveSchema.gen[Person]
}
Self Type
Schema[A]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Schema
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]]

Abstract Value Members

  1. abstract def annotate(annotation: Any): Schema[A]

    Returns a new schema that with annotation

  2. abstract def annotations: Chunk[Any]

    Chunk of annotations for this schema

  3. abstract def defaultValue: Either[String, A]

    The default value for a Schema of type A.

  4. abstract def makeAccessors(b: AccessorBuilder): Accessors[Lens, Prism, Traversal]

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def <*>[B](that: Schema[B]): Schema[(A, B)]

    A symbolic operator for zip.

  4. def <+>[B](that: Schema[B]): Schema[Either[A, B]]

    A symbolic operator for orElseEither.

  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. def ?: Schema[Option[A]]

    A symbolic operator for optional.

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def ast: SchemaAst
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. def coerce[B](newSchema: Schema[B]): Either[String, Schema[B]]

    Convert to Schema[B] iff B and A are homomorphic.

    Convert to Schema[B] iff B and A are homomorphic.

    This can be used to e.g convert between a case class and it's "generic" representation as a ListMap[String,_]

  11. def diff(thisValue: A, thatValue: A, differ: Option[Differ[A]] = None): Diff[A]

    Performs a diff between thisValue and thatValue.

    Performs a diff between thisValue and thatValue. See zio.schema.Differ for details on the default diff algorithms.

    A custom zio.schema.Differ can be supplied if the default behavior is not acceptable.

  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  15. def fromDynamic(value: DynamicValue): Either[String, A]
  16. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def migrate[B](newSchema: Schema[B]): Either[String, (A) => Either[String, B]]

    Generate a homomorphism from A to B iff A and B are homomorphic

  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. def optional: Schema[Option[A]]

    Returns a new schema that modifies the type produced by this schema to be optional.

  24. def orElseEither[B](that: Schema[B]): Schema[Either[A, B]]

    Returns a new schema that combines this schema and the specified schema together, modeling their either composition.

  25. def ordering: Ordering[A]
  26. def patch(oldValue: A, diff: Diff[A]): Either[String, A]

    Patch value with a Diff.

  27. def repeated: Schema[Chunk[A]]
  28. def serializable: Schema[Schema[A]]
  29. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  30. def toDynamic(value: A): DynamicValue
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. def transform[B](f: (A) => B, g: (B) => A): Schema[B]

    Transforms this Schema[A] into a Schema[B], by supplying two functions that can transform between A and B, without possibility of failure.

  33. def transformOrFail[B](f: (A) => Either[String, B], g: (B) => Either[String, A]): Schema[B]

    Transforms this Schema[A] into a Schema[B], by supplying two functions that can transform between A and B (possibly failing in some cases).

  34. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  35. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  36. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  37. def zip[B](that: Schema[B]): Schema[(A, B)]

    Returns a new schema that combines this schema and the specified schema together, modeling their tuple composition.

Inherited from AnyRef

Inherited from Any

Ungrouped