\href{https://npmjs.com/package/schema-utils}{\texttt{ }} \href{https://nodejs.org}{\texttt{ }} \href{https://david-dm.org/webpack-contrib/schema-utils}{\texttt{ }} \href{https://travis-ci.org/webpack-contrib/schema-utils}{\texttt{ }} \href{https://codecov.io/gh/webpack-contrib/schema-utils}{\texttt{ }} \href{https://gitter.im/webpack/webpack}{\texttt{ }}

 \href{http://json-schema.org}{\texttt{  }} \href{https://github.com/webpack/webpack}{\texttt{  }} \doxysection*{Schema Utils}

 

\doxysubsection*{Install}


\begin{DoxyCode}{0}
\DoxyCodeLine{npm i schema-\/utils }

\end{DoxyCode}


\doxysubsection*{Usage}\hypertarget{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32683}{}\doxysubsubsection{$<$tt$>$validate\+Options$<$/tt$>$}\label{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32683}
$\ast$$\ast${\ttfamily schema.\+json}$\ast$$\ast$ 
\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}type"{}: "{}object"{},}
\DoxyCodeLine{  "{}properties"{}: \{}
\DoxyCodeLine{    // Options...}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  "{}additionalProperties"{}: false}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32684}{}\doxyparagraph{Error Messages (\+Custom)}\label{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32684}
$\ast$$\ast${\ttfamily schema.\+json}$\ast$$\ast$ 
\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}type"{}: "{}object"{},}
\DoxyCodeLine{  "{}properties"{}: \{}
\DoxyCodeLine{    "{}option"{}: \{}
\DoxyCodeLine{      "{}type"{}: [ "{}boolean"{} ]}
\DoxyCodeLine{    \}}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  // Overrides the default err.message for option}
\DoxyCodeLine{  "{}errorMessage"{}: \{}
\DoxyCodeLine{    "{}option"{}: "{}should be \{Boolean\} (https:/github.com/org/repo\#anchor)"{}}
\DoxyCodeLine{  \}}
\DoxyCodeLine{  "{}additionalProperties"{}: false}
\DoxyCodeLine{\} }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{import schema from 'path/to/schema.json'}
\DoxyCodeLine{import validateOptions from 'schema-\/utils'}
\DoxyCodeLine{}
\DoxyCodeLine{validateOptions(schema, options, 'Loader/Plugin Name') }

\end{DoxyCode}


\doxysubsection*{Examples}

{\bfseries{schema.\+json}} 
\begin{DoxyCode}{0}
\DoxyCodeLine{\{}
\DoxyCodeLine{  "{}type"{}: "{}object"{},}
\DoxyCodeLine{  "{}properties"{}: \{}
\DoxyCodeLine{    "{}name"{}: \{}
\DoxyCodeLine{      "{}type"{}: "{}string"{}}
\DoxyCodeLine{    \},}
\DoxyCodeLine{    "{}test"{}: \{}
\DoxyCodeLine{      "{}anyOf"{}: [}
\DoxyCodeLine{        \{ "{}type"{}: "{}array"{} \},}
\DoxyCodeLine{        \{ "{}type"{}: "{}string"{} \},}
\DoxyCodeLine{        \{ "{}instanceof"{}: "{}RegExp"{} \}}
\DoxyCodeLine{      ]}
\DoxyCodeLine{    \},}
\DoxyCodeLine{    "{}transform"{}: \{}
\DoxyCodeLine{      "{}instanceof"{}: "{}Function"{}}
\DoxyCodeLine{    \},}
\DoxyCodeLine{    "{}sourceMap"{}: \{}
\DoxyCodeLine{      "{}type"{}: "{}boolean"{}}
\DoxyCodeLine{    \}}
\DoxyCodeLine{  \},}
\DoxyCodeLine{  "{}additionalProperties"{}: false}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32685}{}\doxysubsubsection{$<$tt$>$\+Loader$<$/tt$>$}\label{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32685}

\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ getOptions \} from 'loader-\/utils'}
\DoxyCodeLine{import validateOptions from 'schema-\/utils'}
\DoxyCodeLine{}
\DoxyCodeLine{import schema from 'path/to/schema.json'}
\DoxyCodeLine{}
\DoxyCodeLine{function loader (src, map) \{}
\DoxyCodeLine{  const options = getOptions(this) || \{\}}
\DoxyCodeLine{}
\DoxyCodeLine{  validateOptions(schema, options, 'Loader Name')}
\DoxyCodeLine{}
\DoxyCodeLine{  // Code...}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32686}{}\doxysubsubsection{$<$tt$>$\+Plugin$<$/tt$>$}\label{md_sfcode_node_modules_webpack_node_modules_schema_utils_README_autotoc_md32686}

\begin{DoxyCode}{0}
\DoxyCodeLine{import validateOptions from 'schema-\/utils'}
\DoxyCodeLine{}
\DoxyCodeLine{import schema from 'path/to/schema.json'}
\DoxyCodeLine{}
\DoxyCodeLine{class Plugin \{}
\DoxyCodeLine{  constructor (options) \{}
\DoxyCodeLine{    validateOptions(schema, options, 'Plugin Name')}
\DoxyCodeLine{}
\DoxyCodeLine{    this.options = options}
\DoxyCodeLine{  \}}
\DoxyCodeLine{}
\DoxyCodeLine{  apply (compiler) \{}
\DoxyCodeLine{    // Code...}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
 