Package-level declarations

Types

Link copied to clipboard
open class ValidatingStore<D, T, M>(initialData: D, validation: Validation<D, T, M>, metadataDefault: T, job: Job, validateAfterUpdate: Boolean = true, val id: String = Id.next()) : RootStore<D>

A ValidatingStore is a Store which also contains a Validation for its model and by default applies it to every update.

Link copied to clipboard
value class Validation<D, T, M>(validate: (Inspector<D>, T) -> List<M>)

Encapsulates the logic for validating a given data-model with metadata.

Link copied to clipboard

Minimal interface for a validation message that exposes the model path for matching relevant sub-model-data and probably relevant UI element representation for showing the message and getting information about the valid state after validation process.

Properties

Link copied to clipboard

Returns true when the list contains no ValidationMessage which is marked with ValidationMessage.isError.

val <M : ValidationMessage> Flow<List<M>>.valid: Flow<Boolean>

Checks if a Flow of a List of ValidationMessages is valid.

Functions

Link copied to clipboard
operator fun <D, M> Validation<D, Unit, M>.invoke(data: D): List<M>
operator fun <D, M> Validation<D, Unit, M>.invoke(inspector: Inspector<D>): List<M>

Convenience execution function for Validation for the case, that the metadata is Unit. In those cases the metadata parameter can be omitted.

Link copied to clipboard
fun <M : ValidationMessage> Store<*>.messages(): Flow<List<M>>?

Finds all exactly corresponding ValidationMessages to this Store, which means all messages, which have exactly the same path as the Store.

fun <M : ValidationMessage> Store<*>.messages(filterPredicate: (M) -> Boolean): Flow<List<M>>?

Finds all corresponding ValidationMessages to this Store which satisfy the filterPredicate-expression.

Link copied to clipboard

Finds all corresponding ValidationMessages to this Store, which means all messages, that fit exactly with their path or which are sub-elements of this Stores data model.

Link copied to clipboard
fun <D, M> storeOf(initialData: D, validation: Validation<D, Unit, M>, job: Job, id: String = Id.next()): ValidatingStore<D, Unit, M>

Convenience function to create a simple ValidatingStore without any metadata and handlers.

fun <D, T, M> storeOf(initialData: D, validation: Validation<D, T, M>, metadataDefault: T, job: Job = Job(), id: String = Id.next()): ValidatingStore<D, T, M>

Convenience function to create a simple ValidatingStore without any handlers, etc.

Link copied to clipboard
fun <D, M> WithJob.storeOf(initialData: D, validation: Validation<D, Unit, M>, job: Job = this.job, id: String = Id.next()): ValidatingStore<D, Unit, M>

Convenience function to create a simple ValidatingStore without any metadata and handlers.

fun <D, T, M> WithJob.storeOf(initialData: D, validation: Validation<D, T, M>, metadataDefault: T, job: Job = this.job, id: String = Id.next()): ValidatingStore<D, T, M>

Convenience function to create a simple ValidatingStore without any handlers, etc.

Link copied to clipboard
fun <D, M> validation(validate: MutableList<M>.(Inspector<D>) -> Unit): Validation<D, Unit, M>

Convenience function for creating a Validation instance only accepting model-data by working on a MutableList receiver and using an Inspector for getting the right Inspector.path from sub-models next to the Inspector.data.

fun <D, T, M> validation(validate: MutableList<M>.(Inspector<D>, T) -> Unit): Validation<D, T, M>

Convenience function for creating a Validation instance accepting model- and metadata by working on a MutableList receiver and using an Inspector for getting the right Inspector.path from sub-models next to the Inspector.data.