DynamicValueSelection

zio.blocks.schema.DynamicValueSelection
See theDynamicValueSelection companion object
final case class DynamicValueSelection(either: Either[SchemaError, Chunk[DynamicValue]]) extends AnyVal

A wrapper around Either[SchemaError, Chunk[DynamicValue]] that provides fluent chaining for DynamicValue navigation and querying operations.

DynamicValueSelection enables a fluent API style for navigating through DynamicValue structures:

val dv = DynamicValue.Record(
 "users" -> DynamicValue.Sequence(
   DynamicValue.Record("name" -> DynamicValue.string("Alice"))
 )
)

val names: DynamicValueSelection =
 dv.get("users").sequences.apply(0).get("name").primitives

The selection can contain zero, one, or multiple DynamicValue values, supporting both single-value navigation and multi-value queries.

Attributes

Companion
object
Source
DynamicValueSelection.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class AnyVal
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Combines two selections, concatenating their values.

Combines two selections, concatenating their values.

Attributes

Source
DynamicValueSelection.scala
def all: Either[SchemaError, DynamicValue]

Returns all selected values condensed into a single DynamicValue. If there are multiple values, wraps them in a Sequence. Fails if the selection is empty or an error.

Returns all selected values condensed into a single DynamicValue. If there are multiple values, wraps them in a Sequence. Fails if the selection is empty or an error.

Attributes

Source
DynamicValueSelection.scala
def any: Either[SchemaError, DynamicValue]

Returns any single value from the selection. Fails if the selection is empty or an error.

Returns any single value from the selection. Fails if the selection is empty or an error.

Attributes

Source
DynamicValueSelection.scala

Unsafe version of any - throws SchemaError on error.

Unsafe version of any - throws SchemaError on error.

Attributes

Source
DynamicValueSelection.scala
def apply(index: Int): DynamicValueSelection

Navigates to an index in each sequence.

Navigates to an index in each sequence.

Attributes

Source
DynamicValueSelection.scala
def apply(fieldName: String): DynamicValueSelection

Navigates to a field in each record (alias for get).

Navigates to a field in each record (alias for get).

Attributes

Source
DynamicValueSelection.scala

Navigates using a DynamicOptic path (alias for get).

Navigates using a DynamicOptic path (alias for get).

Attributes

Source
DynamicValueSelection.scala
def as(t: DynamicValueType): Either[SchemaError, t.Type]

Narrows the single selected value to the specified DynamicValue type. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Narrows the single selected value to the specified DynamicValue type. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Attributes

Source
DynamicValueSelection.scala

Narrows all selected values to the specified DynamicValue type. Values not matching the type are silently dropped.

Narrows all selected values to the specified DynamicValue type. Values not matching the type are silently dropped.

Attributes

Source
DynamicValueSelection.scala
def asPrimitive[A](pt: PrimitiveType[A]): Either[SchemaError, A]

Extracts a primitive value of type A from the single selected value. Fails if there are 0 or more than 1 values, or if the value isn't the expected primitive.

Extracts a primitive value of type A from the single selected value. Fails if there are 0 or more than 1 values, or if the value isn't the expected primitive.

Attributes

Source
DynamicValueSelection.scala
def asPrimitiveAll[A](pt: PrimitiveType[A]): Either[SchemaError, Chunk[A]]

Extracts primitive values of type A from all selected values. Values not matching the type are silently dropped.

Extracts primitive values of type A from all selected values. Values not matching the type are silently dropped.

Attributes

Source
DynamicValueSelection.scala
def collect[A](pf: PartialFunction[DynamicValue, A]): Either[SchemaError, Chunk[A]]

Collects values for which the partial function is defined.

Collects values for which the partial function is defined.

Attributes

Source
DynamicValueSelection.scala

Deletes the value at the given path in each selected value.

Deletes the value at the given path in each selected value.

Attributes

Source
DynamicValueSelection.scala

Deletes the value at the given path. Fails if the path doesn't exist.

Deletes the value at the given path. Fails if the path doesn't exist.

Attributes

Source
DynamicValueSelection.scala

Recursively removes empty Records, Sequences, and Maps in each selected value.

Recursively removes empty Records, Sequences, and Maps in each selected value.

Attributes

Source
DynamicValueSelection.scala

Recursively removes all Null values from containers in each selected value.

Recursively removes all Null values from containers in each selected value.

Attributes

Source
DynamicValueSelection.scala

Recursively removes all Primitive(Unit) values from containers in each selected value.

Recursively removes all Primitive(Unit) values from containers in each selected value.

Attributes

Source
DynamicValueSelection.scala
def error: Option[SchemaError]

Returns the error if this is a failure, otherwise None.

Returns the error if this is a failure, otherwise None.

Attributes

Source
DynamicValueSelection.scala

Filters by DynamicValueType.

Filters by DynamicValueType.

Attributes

Source
DynamicValueSelection.scala

Filters selected values based on a predicate.

Filters selected values based on a predicate.

Attributes

Source
DynamicValueSelection.scala

FlatMaps a function over all selected values, combining results.

FlatMaps a function over all selected values, combining results.

Attributes

Source
DynamicValueSelection.scala
def get(fieldName: String): DynamicValueSelection

Navigates to a field in each record.

Navigates to a field in each record.

Attributes

Source
DynamicValueSelection.scala

Navigates to a map entry by key.

Navigates to a map entry by key.

Attributes

Source
DynamicValueSelection.scala

Navigates using a DynamicOptic path.

Navigates using a DynamicOptic path.

Attributes

Source
DynamicValueSelection.scala
def getCase(caseName: String): DynamicValueSelection

Navigates into a variant case.

Navigates into a variant case.

Attributes

Source
DynamicValueSelection.scala

Returns this selection's values, or the default on failure.

Returns this selection's values, or the default on failure.

Attributes

Source
DynamicValueSelection.scala

Inserts a value at the given path in each selected value.

Inserts a value at the given path in each selected value.

Attributes

Source
DynamicValueSelection.scala

Inserts a value at the given path. Fails if the path already exists or the parent doesn't exist.

Inserts a value at the given path. Fails if the path already exists or the parent doesn't exist.

Attributes

Source
DynamicValueSelection.scala
def isEmpty: Boolean

Returns true if this selection is empty (no values or error).

Returns true if this selection is empty (no values or error).

Attributes

Source
DynamicValueSelection.scala
def isFailure: Boolean

Returns true if the selection is a failure.

Returns true if the selection is a failure.

Attributes

Source
DynamicValueSelection.scala
def isSuccess: Boolean

Returns true if the selection is successful (contains values).

Returns true if the selection is successful (contains values).

Attributes

Source
DynamicValueSelection.scala

Maps a function over all selected values.

Maps a function over all selected values.

Attributes

Source
DynamicValueSelection.scala

Keeps only map values.

Keeps only map values.

Attributes

Source
DynamicValueSelection.scala

Merges each value in this selection with each value in that selection. Uses cartesian product semantics: if this has N values and that has M values, the result has N × M values.

Merges each value in this selection with each value in that selection. Uses cartesian product semantics: if this has N values and that has M values, the result has N × M values.

Attributes

Source
DynamicValueSelection.scala

Modifies the value at the given path in each selected value.

Modifies the value at the given path in each selected value.

Attributes

Source
DynamicValueSelection.scala

Modifies values at the given path using a partial function. Fails if the path doesn't exist or the partial function is not defined.

Modifies values at the given path using a partial function. Fails if the path doesn't exist or the partial function is not defined.

Attributes

Source
DynamicValueSelection.scala
def nonEmpty: Boolean

Returns true if this selection contains at least one value.

Returns true if this selection contains at least one value.

Attributes

Source
DynamicValueSelection.scala

Applies sortFields, sortMapKeys, dropNulls, dropUnits, and dropEmpty to each selected value.

Applies sortFields, sortMapKeys, dropNulls, dropUnits, and dropEmpty to each selected value.

Attributes

Source
DynamicValueSelection.scala

Keeps only null values.

Keeps only null values.

Attributes

Source
DynamicValueSelection.scala
def one: Either[SchemaError, DynamicValue]

Returns the single selected value, or fails if there are 0 or more than 1 values.

Returns the single selected value, or fails if there are 0 or more than 1 values.

Attributes

Source
DynamicValueSelection.scala

Unsafe version of one - throws SchemaError on error.

Unsafe version of one - throws SchemaError on error.

Attributes

Source
DynamicValueSelection.scala

Returns this selection if successful, otherwise the alternative.

Returns this selection if successful, otherwise the alternative.

Attributes

Source
DynamicValueSelection.scala

Keeps only primitive values.

Keeps only primitive values.

Attributes

Source
DynamicValueSelection.scala

Projects each selected value to only include the specified paths.

Projects each selected value to only include the specified paths.

Attributes

Source
DynamicValueSelection.scala

Removes values matching the predicate from each selected value.

Removes values matching the predicate from each selected value.

Attributes

Source
DynamicValueSelection.scala

Removes values matching both path and value predicates from each selected value.

Removes values matching both path and value predicates from each selected value.

Attributes

Source
DynamicValueSelection.scala

Removes values at paths matching the predicate from each selected value.

Removes values at paths matching the predicate from each selected value.

Attributes

Source
DynamicValueSelection.scala

Recursively searches each DynamicValue in the selection, collecting all values for which the predicate returns true.

Recursively searches each DynamicValue in the selection, collecting all values for which the predicate returns true.

Attributes

Source
DynamicValueSelection.scala

Recursively searches each DynamicValue in the selection, collecting all values for which the predicate on both path and value returns true.

Recursively searches each DynamicValue in the selection, collecting all values for which the predicate on both path and value returns true.

Attributes

Source
DynamicValueSelection.scala

Recursively searches each DynamicValue in the selection, collecting all values at paths for which the predicate returns true.

Recursively searches each DynamicValue in the selection, collecting all values at paths for which the predicate returns true.

Attributes

Source
DynamicValueSelection.scala

Keeps only record values.

Keeps only record values.

Attributes

Source
DynamicValueSelection.scala

Retains only values matching the predicate in each selected value.

Retains only values matching the predicate in each selected value.

Attributes

Source
DynamicValueSelection.scala

Retains only values matching both path and value predicates in each selected value.

Retains only values matching both path and value predicates in each selected value.

Attributes

Source
DynamicValueSelection.scala

Retains only values at paths matching the predicate in each selected value.

Retains only values at paths matching the predicate in each selected value.

Attributes

Source
DynamicValueSelection.scala

Keeps only sequence values.

Keeps only sequence values.

Attributes

Source
DynamicValueSelection.scala

Sets a value at the given path in each selected value.

Sets a value at the given path in each selected value.

Attributes

Source
DynamicValueSelection.scala

Sets a value at the given path. Fails if the path doesn't exist.

Sets a value at the given path. Fails if the path doesn't exist.

Attributes

Source
DynamicValueSelection.scala
def size: Int

Returns the number of selected values (0 on error).

Returns the number of selected values (0 on error).

Attributes

Source
DynamicValueSelection.scala

Recursively sorts all record fields alphabetically in each selected value.

Recursively sorts all record fields alphabetically in each selected value.

Attributes

Source
DynamicValueSelection.scala

Recursively sorts all map entries by key in each selected value.

Recursively sorts all map entries by key in each selected value.

Attributes

Source
DynamicValueSelection.scala

Returns the selected values as a Chunk, or an empty Chunk on failure.

Returns the selected values as a Chunk, or an empty Chunk on failure.

Attributes

Source
DynamicValueSelection.scala

Returns all selected values as a DynamicValue.Sequence.

Returns all selected values as a DynamicValue.Sequence.

Attributes

Source
DynamicValueSelection.scala

Transforms each selected value top-down using the given function.

Transforms each selected value top-down using the given function.

Attributes

Source
DynamicValueSelection.scala
def transformFields(f: (DynamicOptic, String) => String): DynamicValueSelection

Transforms all record field names in each selected value using the given function.

Transforms all record field names in each selected value using the given function.

Attributes

Source
DynamicValueSelection.scala

Transforms all map keys in each selected value using the given function.

Transforms all map keys in each selected value using the given function.

Attributes

Source
DynamicValueSelection.scala

Transforms each selected value bottom-up using the given function.

Transforms each selected value bottom-up using the given function.

Attributes

Source
DynamicValueSelection.scala

Extracts the underlying Scala value from the single selected DynamicValue. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Extracts the underlying Scala value from the single selected DynamicValue. Fails if there are 0 or more than 1 values, or if the value doesn't match.

Attributes

Source
DynamicValueSelection.scala

Extracts the underlying Scala values from all selected DynamicValues. Values not matching the type are silently dropped.

Extracts the underlying Scala values from all selected DynamicValues. Values not matching the type are silently dropped.

Attributes

Source
DynamicValueSelection.scala
def values: Option[Chunk[DynamicValue]]

Returns the selected values if successful, otherwise None.

Returns the selected values if successful, otherwise None.

Attributes

Source
DynamicValueSelection.scala

Keeps only variant values.

Keeps only variant values.

Attributes

Source
DynamicValueSelection.scala

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala