Example usages of ZIO-Schema, mainly used as a cheatsheet and making sure the examples work when putting them into the documentation.
Basic domain model and showing how to create a schema by hand and by macro derivation. Showing how to transform a JSON-String to a domain object using a codec.
Schema definitions in companion objects.
In this example we'll take a look on how to use ZIO-Schema to transform the JSON of a PersonDTO (e.g. from a REST API) into a Person (e.g. for a database) in a single step.
To do this, we'll transform the Schema of the PersonDTO into a Schema of the Person.
In this example we'll take a look on how to use ZIO-Schema to migrate between different objects,
e.g. a WebPerson
to a DomainPerson
In this example we'll see how we can use ZIO-Schema to create Diffs between two objects. This is helpful e.g. to only persist changes to objects, e.g. when using EventSourcing.
In this example we'll see how we can use optics generated by ZIO-Schema to manipulate nested data structures.
- use lenses to change simple values (lenstest1)
- use lenses to change values in nested classes (lenstest2)
- use traversable to add elements to a list in a nested class (traversabletest1)
Example based on John DeGoes Spartan Training on ZIO-Schema from 2021-11-04. We're building a QueryString-Codec.