SchemaMatch

zio.blocks.schema.SchemaMatch
object SchemaMatch

Provides matching logic for SchemaRepr patterns against DynamicValue instances.

This object implements structural pattern matching between schema representations and runtime dynamic values, enabling the search optic to find values that match a given schema pattern.

==Matching Rules==

  • '''Wildcard''': Matches any DynamicValue
  • '''Primitive(name)''': Matches DynamicValue.Primitive where the underlying PrimitiveValue type matches the name (case-insensitive)
  • '''Record(fields)''': Matches DynamicValue.Record using subset matching - all specified fields must exist with matching types, but extra fields are allowed
  • '''Variant(cases)''': Matches DynamicValue.Variant if the case name matches one of the pattern cases and the payload matches that case's pattern
  • '''Sequence(elem)''': Matches DynamicValue.Sequence if all elements match the element pattern (empty sequence always matches)
  • '''Map(k, v)''': Matches DynamicValue.Map if all entries have matching key and value types (empty map always matches)
  • '''Optional(inner)''': Matches DynamicValue.Null always, otherwise checks inner pattern
  • '''Nominal(name)''': Returns false (requires schema context not available in DynamicValue)

Attributes

Source
SchemaMatch.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def matches(pattern: SchemaRepr, value: DynamicValue): Boolean

Tests whether a DynamicValue matches a SchemaRepr pattern.

Tests whether a DynamicValue matches a SchemaRepr pattern.

Value parameters

pattern

the schema pattern to match against

value

the dynamic value to check

Attributes

Returns

true if the value matches the pattern, false otherwise

Source
SchemaMatch.scala