ValidatingStore
A ValidatingStore is a Store which also contains a Validation for its model and by default applies it to every update.
This store is intentionally configured to validate the data on each update, that is why the validateAfterUpdate parameter is set to true
by default.
There might be special situations where it is reasonable to disable this behaviour by setting validateAfterUpdate to false
and to prefer applying the validation individually within custom handlers, for example if a model should only be validated after the user has completed his input or if metadata is needed for the validation process. Then be aware of the fact, that the call of the validate function actually updates the messages already.
In order for the automatic validation to work, a metadataDefault value must be specified. This is needed due to no specific metadata being present during automatic validation. When calling validate manually, the appropriate metadata can be supplied directly.
If the new data is not passed to the store's state after validating it, the messages are probably out of sync with the actual store's state! This could lead to false assumptions and might produce hard to detect bugs in your application.
Parameters
first current value of this Store
Validation function to use at the data on this Store.
default metadata to be used by the automatic validation (where no explicit values are given)
Job to be used by the Store
flag to decide if a new value gets automatically validated after setting it to the Store.
Properties
a simple SimpleHandler that just takes the given action-value as the new value for the Store.
Functions
Default error handler printing the error to console.
Factory method to create a SimpleHandler that does not take an Action
Factory method to create a SimpleHandler mapping the actual value of the Store and a given Action to a new value.
factory method to create an EmittingHandler that does not take an action in it's execute-lambda.
Factory method to create a EmittingHandler taking an action-value and the current store value to derive the new value. An EmittingHandler is a Flow by itself and can therefore be connected to other SimpleHandlers even in other Stores.
on a Store of nullable data this creates a Store with a nullable parent and non-nullable value. It can be called using a Lens on a non-nullable parent (that can be created by using the @Lenses-annotation), but you have to ensure, that the resulting Store is never used, when it's parent's value is null. Otherwise, a NullPointerException is thrown.
Finds all exactly corresponding ValidationMessages to this Store, which means all messages, which have exactly the same path as the Store.
Finds all corresponding ValidationMessages to this Store which satisfy the filterPredicate-expression.
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.