A {\itshape plain object}


\begin{DoxyItemize}
\item Inherits directly from {\ttfamily Object.\+prototype} or {\ttfamily null}
\item Is not a constructor\textquotesingle{}s {\ttfamily prototype} property
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9969}{}\doxysection{$<$tt$>$plain-\/object/is$<$/tt$>$}\label{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9969}
Confirms if given object is a {\itshape plain object}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isPlainObject = require("{}type/plain-\/object/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isPlainObject(\{\}); // true}
\DoxyCodeLine{isPlainObject(Object.create(null)); // true}
\DoxyCodeLine{isPlainObject([]); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9970}{}\doxysection{$<$tt$>$plain-\/object/ensure$<$/tt$>$}\label{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9970}
If given argument is a plain object it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensurePlainObject = require("{}type/plain-\/object/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensurePlainObject(\{\}); // \{\}}
\DoxyCodeLine{ensurePlainObject("{}foo"{}); // Thrown TypeError: foo is not a plain object }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9971}{}\doxysubsection{Confirming on keys}\label{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9971}
Keys can be validated by passing {\ttfamily allowed\+Keys} option. Note that in this case\+:


\begin{DoxyItemize}
\item Error message lists up to three invalid keys
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{const allowedKeys = ["{}foo"{}];}
\DoxyCodeLine{}
\DoxyCodeLine{ensurePlainObject(\{\}, \{ allowedKeys \}); // \{\}}
\DoxyCodeLine{ensurePlainObject(\{ foo: "{}bar"{} \}, \{ allowedKeys \}); // \{ foo: 'bar' \}}
\DoxyCodeLine{}
\DoxyCodeLine{/*}
\DoxyCodeLine{ Below invocation with crash with:}
\DoxyCodeLine{ TypeError: [object Object] is not a valid plain object.}
\DoxyCodeLine{            Following keys are unexpected: lorem, ipsum}
\DoxyCodeLine{*/}
\DoxyCodeLine{ensurePlainObject(\{ foo: "{}bar"{}, lorem: 1, ipsum: 2 \}, \{ allowedKeys \}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9972}{}\doxysubsection{Confirming on property values}\label{md_sfcode_node_modules_ext_node_modules_type_docs_plain_object_autotoc_md9972}
Property values can be validated by passing {\ttfamily ensure\+Property\+Value} option. Note that in this case\+:


\begin{DoxyItemize}
\item A newly created instance of plain object with coerced values is returned
\item Error message lists up to three keys that contain invalid values
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureString = require("{}type/string/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensurePlainObject(\{ foo: 12 \}, \{ ensurePropertyValue: ensureString \}); // \{ foo: '12' \}}
\DoxyCodeLine{}
\DoxyCodeLine{/*}
\DoxyCodeLine{ Below invocation with crash with:}
\DoxyCodeLine{ TypeError: [object Object] is not a valid plain object.}
\DoxyCodeLine{            Valuees for following keys are invalid: lorem, ipsum}
\DoxyCodeLine{*/}
\DoxyCodeLine{ensurePlainObject(\{ foo: 23, lorem: \{\}, ipsum: \{\} \}, \{ ensurePropertyValue: ensureString \}); }

\end{DoxyCode}
 