Skip to content

Heterogeneous

class Heterogeneous<T>(
    val items: List<Schema<T>>, 
    val additionalItems: Schema<T>?, 
    factory: BsonFactory
) : Schema.ArrayItems.ArrayItemsConfiguration<T> 

Pass this value to ArrayItems to specify that each item has its own schema.

Constructors

Heterogeneous

constructor(
    items: List<Schema<T>>, 
    additionalItems: Schema<T>?, 
    factory: BsonFactory
)

Properties

additionalItems

If there are more items in the array than in items, this property controls whether validation succeeds.

If additionalItems is null, validation fails: the array must contain the exact same number of items as items.

If additionalItems is not null, all additional items are validated against this schema.

items

val items: List<Schema<T>>

Defines the schema of the different items in this array.

  • The first item in the array must match the schema defined at index 0.

  • The second item in the array must match the schema defined at index 1.

  • The third item in the array must match the schema defined at index 2.

  • Etc.

If there are more items in the array than there are schemas, the validation is controlled by the additionalItems field.

If there are fewer items in the array than there are schemas, the validation succeeds.

Must not be empty.

Functions

toString

open override fun toString(): String

JSON representation of this object as a BSON document.

writeTo

@LowLevelApi
open override fun writeTo(writer: BsonFieldWriter)

Writes this object to the provided writer.