
\begin{DoxyItemize}
\item infos = Information about the enum plugin is in keys below
\item infos/author = Thomas Waser \href{mailto:thomas.waser@libelektra.org}{\tt thomas.\+waser@libelektra.\+org}
\item infos/licence = B\+SD
\item infos/provides = check
\item infos/needs =
\item infos/recommends =
\item infos/placements = presetstorage postgetstorage
\item infos/status = productive maintained unittest tested nodep libc
\item infos/metadata = check/enum check/enum/\# check/enum/multi
\item infos/description = validates values against enum
\end{DoxyItemize}

The enum plugin checks string values of Keys by comparing it against a list of valid values.

\subsection*{Usage}

The plugin checks every Key in the Keyset for the Metakey {\ttfamily check/enum} containing a list with the syntax `\textquotesingle{}string1\textquotesingle{}, \textquotesingle{}string2\textquotesingle{}, \textquotesingle{}string3\textquotesingle{}, ..., \textquotesingle{}stringN\textquotesingle{}` and compares each value with the string value of the Key. If no match is found an error is returned.

Alternatively, if {\ttfamily check/enum} starts with {\ttfamily \#}, a meta array {\ttfamily check/enum} is used. For example\+: \begin{DoxyVerb}check/enum = #3
check/enum/#0 = small
check/enum/#1 = middle
check/enum/#2 = large
check/enum/#3 = huge
\end{DoxyVerb}


Furthermore {\ttfamily check/enum/multi} may contain a separator character, that separates multiple allowed occurrences. For example\+: \begin{DoxyVerb}check/enum/multi = _
\end{DoxyVerb}


Then the value {\ttfamily middle\+\_\+small} would validate. But {\ttfamily middle\+\_\+small\+\_\+small} would fail because every entry might only occur once.

\subsection*{Example}


\begin{DoxyCode}
# Backup-and-Restore:/tests/enum

sudo kdb mount enum.ecf /tests/enum enum dump

# valid initial value + setup valid enum list
kdb set /tests/enum/value middle
kdb setmeta /tests/enum/value check/enum "'low', 'middle', 'high'"

# should succeed
kdb set /tests/enum/value low

# should fail with error 121
kdb set /tests/enum/value no
# RET:5
# ERROR:121
\end{DoxyCode}


Or with multi-\/enums\+:


\begin{DoxyCode}
# valid initial value + setup array with valid enums
kdb set /tests/enum/multivalue middle\_small
kdb setmeta /tests/enum/multivalue check/enum/#0 small
kdb setmeta /tests/enum/multivalue check/enum/#1 middle
kdb setmeta /tests/enum/multivalue check/enum/#2 large
kdb setmeta /tests/enum/multivalue check/enum/#3 huge
kdb setmeta /tests/enum/multivalue check/enum/multi \_
kdb setmeta /tests/enum/multivalue check/enum "#3"

# should succeed
kdb set /tests/enum/multivalue \_\_\_small\_middle\_\_

# should fail with error 121
kdb set /tests/enum/multivalue \_\_\_all\_small\_\_
# RET:5
# ERROR:121

# cleanup
kdb rm -r /tests/enum
sudo kdb umount /tests/enum
\end{DoxyCode}


\subsection*{Limitations}

You cannot give enum values specific values. If you only want to check for numerical values, the plugin \hyperlink{md_src_plugins_range_README_src_plugins_range_README_md}{range} is better suited. 