\label{doc_decisions_validation_md_md_doc_decisions_validation}%
\Hypertarget{doc_decisions_validation_md_md_doc_decisions_validation}%
 \hypertarget{doc_decisions_validation_md_autotoc_md2322}{}\doxysection{Problem}\label{doc_decisions_validation_md_autotoc_md2322}
Validation plugins operate as independent blackboxes. For every backend each mounted validation plugin iterates over the whole keyset, checks every key for its trigger metakey, and validates the key.

Currently all needed validation plugins need to be specified at mount-\/time -\/ if additional validation is required, the backend has to be remounted with the required plugins and plugin configuration.

If validation of a key fails, each plugin decides on its own how to handle the issue and proceed in ways that might be different from what is expected or desired.\hypertarget{doc_decisions_validation_md_autotoc_md2323}{}\doxysection{Constraints}\label{doc_decisions_validation_md_autotoc_md2323}
\hypertarget{doc_decisions_validation_md_autotoc_md2324}{}\doxysection{Assumptions}\label{doc_decisions_validation_md_autotoc_md2324}
While plugins should always fail and return an error if validation fails on kdb\+Set, there are several different requirements for what should happen on kdb\+Get and handle problems e.\+g.


\begin{DoxyItemize}
\item only issue warnings

we want to read the whole configuration, but issue warnings if keys fail to validate instead

problems are handled external by an application, user, ...
\item remove invalid keys

we want to read the whole configuration, but drop invalid keys

invalid keys might be replaced by default values, requested from the user, ...
\item fail with error

we only want to read valid configurations, and fail with an error if the configuration is invalid
\end{DoxyItemize}\hypertarget{doc_decisions_validation_md_autotoc_md2325}{}\doxysection{Considered Alternatives}\label{doc_decisions_validation_md_autotoc_md2325}

\begin{DoxyItemize}
\item Extend validation plugins to allow us to specify what should happen if a key fails to validate
\item Export a validation function that allows us to use an additional plugin to decide what should be done
\end{DoxyItemize}\hypertarget{doc_decisions_validation_md_autotoc_md2326}{}\doxysection{Decision}\label{doc_decisions_validation_md_autotoc_md2326}
Use a wrapper plugin to iterate over the keyset and delegate the validation of each key to the corresponding validation plugin.\hypertarget{doc_decisions_validation_md_autotoc_md2327}{}\doxysection{Rationale}\label{doc_decisions_validation_md_autotoc_md2327}

\begin{DoxyItemize}
\item Validation plugins don\textquotesingle{}t need to know what should be done if the validation fails
\item We can run multiple validations on every key and improve error messages
\item Different ways of handling errors only need to be implemented once
\end{DoxyItemize}\hypertarget{doc_decisions_validation_md_autotoc_md2328}{}\doxysection{Implications}\label{doc_decisions_validation_md_autotoc_md2328}
validation plugins have to export their validation routine

{\ttfamily static int validate\+Key(const Key $\ast$ key, const Key $\ast$ error\+Key)}

returning 1 if validation succeeded, 0 on failure\hypertarget{doc_decisions_validation_md_autotoc_md2329}{}\doxysection{Related Decisions}\label{doc_decisions_validation_md_autotoc_md2329}
\hypertarget{doc_decisions_validation_md_autotoc_md2330}{}\doxysection{Notes}\label{doc_decisions_validation_md_autotoc_md2330}
