validate

open fun validate(message: String, predicate: (T) -> Boolean): CollectionOptionBuilder<T, C>(source)

Adds validation for individual elements in the collection. The validation is applied to each element that is added to the collection.

Return

This builder for method chaining

Parameters

message

Error message to display if validation fails

predicate

Function that returns true if the element is valid