zio.blocks.schema.derive
Members list
Type members
Classlikes
Attributes
- Companion
- class
- Source
- BindingInstance.scala
- Supertypes
- Self type
-
BindingInstance.type
Attributes
- Companion
- object
- Source
- BindingInstance.scala
- Supertypes
Attributes
- Companion
- trait
- Source
- Derivable.scala
- Supertypes
- Self type
-
Derivable.type
Attributes
- Companion
- object
- Source
- Derivable.scala
- Supertypes
A DerivationBuilder is capable of deriving a type class instance for any data type that has a schema. Though instances for all substructures can be derived automatically, you can also specify instances for specific substructures using the instance method, and modifiers for them using the modifier method.
A DerivationBuilder is capable of deriving a type class instance for any data type that has a schema. Though instances for all substructures can be derived automatically, you can also specify instances for specific substructures using the instance method, and modifiers for them using the modifier method.
import zio.blocks.schema.json._
case class Person(name: String, age: Int)
object Person extends CompanionOptics[Person] {
implicit val schema: Schema[Person] = Schema.derived
val name: Lens[Person, String] = $(_.name)
val age: Lens[Person, Int] = $(_.age)
}
val personCodec: JsonCodec[Person] = Person.schema
.deriving(JsonCodecDeriver)
.instance(Person.age, JsonCodec.intCodec)
.modifier(Person.name, Modifier.rename("fullName"))
.derive
Attributes
- Source
- DerivationBuilder.scala
- Supertypes
Attributes
- Source
- Deriver.scala
- Supertypes
- Known subtypes
-
class ConfigDecoderDeriverobject ConfigDecoderDeriverobject AvroCodecDeriverclass BsonCodecDeriverobject BsonCodecDeriverobject CsvCodecDeriverclass JsonCodecDeriverobject JsonCodecDeriverobject MessagePackCodecDeriverobject ThriftCodecDeriverclass ToonCodecDeriverobject ToonCodecDeriverclass XmlCodecDeriverobject XmlCodecDeriverclass YamlCodecDeriverobject YamlCodecDeriverclass DbCodecDeriverobject DbCodecDeriverobject HeaderCodecDeriverobject QueryCodecDeriverShow all
- Self type
-
Deriver[TC]
Attributes
- Source
- HasInstance.scala
- Supertypes
Attributes
- Source
- HasInstances.scala
- Supertypes
An override that supplies a custom type class instance during derivation, bypassing the auto-derived one.
An override that supplies a custom type class instance during derivation, bypassing the auto-derived one.
Resolution priority (highest to lowest):
- InstanceOverrideByOptic — matches an exact path in the schema tree
- InstanceOverrideByTypeAndTermName — matches a term (field or case) name inside a specific parent record/variant
- InstanceOverrideByType — matches every occurrence of a type
Attributes
- Source
- InstanceOverride.scala
- Supertypes
- Known subtypes
-
Overrides the type class instance for the substructure at an exact path in the schema tree.
Overrides the type class instance for the substructure at an exact path in the schema tree.
This is the most precise override: it targets one specific location identified by a DynamicOptic. Created via DerivationBuilder.instance(optic, instance).
Attributes
- Source
- InstanceOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait InstanceOverrideclass Objecttrait Matchableclass AnyShow all
Overrides the type class instance for every occurrence of a type, regardless of where it appears in the schema tree.
Overrides the type class instance for every occurrence of a type, regardless of where it appears in the schema tree.
This is the least precise override. Created via DerivationBuilder.instance(typeId, instance).
Attributes
- Source
- InstanceOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait InstanceOverrideclass Objecttrait Matchableclass AnyShow all
Overrides the type class instance for a term (record field or variant case) with a specific name inside a parent record or variant identified by its TypeId. Applies at every matching (parentTypeId, termName) pair in the schema tree.
Overrides the type class instance for a term (record field or variant case) with a specific name inside a parent record or variant identified by its TypeId. Applies at every matching (parentTypeId, termName) pair in the schema tree.
This provides medium precision between InstanceOverrideByOptic and InstanceOverrideByType. Created via DerivationBuilder.instance(typeId, termName, instance).
Attributes
- Source
- InstanceOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait InstanceOverrideclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Source
- Instances.scala
- Supertypes
- Self type
-
Instances.type
Attributes
- Companion
- object
- Source
- Instances.scala
- Supertypes
An override that attaches a Modifier to a schema node during derivation.
An override that attaches a Modifier to a schema node during derivation.
Unlike InstanceOverride, modifier overrides are additive: when multiple overrides match the same node, their modifiers are combined (optic-matched modifiers are prepended before type-matched ones).
Attributes
- Source
- ModifierOverride.scala
- Supertypes
- Known subtypes
-
class ModifierReflectOverrideByType[A]class ModifierTermOverrideByOptic[A]class ModifierTermOverrideByType[A]
Attaches a Modifier.Reflect to the schema node at an exact path in the schema tree.
Attaches a Modifier.Reflect to the schema node at an exact path in the schema tree.
Created via DerivationBuilder.modifier(optic, modifier) when the modifier is a Modifier.Reflect.
Attributes
- Source
- ModifierOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ModifierOverrideclass Objecttrait Matchableclass AnyShow all
Attaches a Modifier.Reflect to every schema node whose type matches the given TypeId.
Attaches a Modifier.Reflect to every schema node whose type matches the given TypeId.
Created via DerivationBuilder.modifier(typeId, modifier).
Attributes
- Source
- ModifierOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ModifierOverrideclass Objecttrait Matchableclass AnyShow all
Attaches a Modifier.Term to a specific term (field or case) within the schema node at an exact path. The termName identifies which field or case within the matched node receives the modifier.
Attaches a Modifier.Term to a specific term (field or case) within the schema node at an exact path. The termName identifies which field or case within the matched node receives the modifier.
Created via DerivationBuilder.modifier(optic, modifier) when the modifier is a Modifier.Term. The optic's last node is extracted as the term name, and the remaining prefix becomes the path.
Attributes
- Source
- ModifierOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ModifierOverrideclass Objecttrait Matchableclass AnyShow all
Attaches a Modifier.Term to a specific term (field or case) within every schema node whose type matches the given TypeId. The termName identifies which field or case within the matched node receives the modifier.
Attaches a Modifier.Term to a specific term (field or case) within every schema node whose type matches the given TypeId. The termName identifies which field or case within the matched node receives the modifier.
Attributes
- Source
- ModifierOverride.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ModifierOverrideclass Objecttrait Matchableclass AnyShow all