Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/schema-utils/ |
Upload File : |
[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![test][test]][test-url] [![coverage][cover]][cover-url] [![chat][chat]][chat-url] <div align="center"> <a href="http://json-schema.org"> <img width="160" height="160" src="https://raw.githubusercontent.com/webpack-contrib/schema-utils/master/docs/logo.png"> </a> <a href="https://github.com/webpack/webpack"> <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"> </a> <h1>Schema Utils</h1> </div> <h2 align="center">Install</h2> ```bash npm i schema-utils ``` <h2 align="center">Usage</h2> ### `validateOptions` **schema.json** ```js { "type": "object", "properties": { // Options... }, "additionalProperties": false } ``` ```js import schema from 'path/to/schema.json' import validateOptions from 'schema-utils' validateOptions(schema, options, 'Loader/Plugin Name') ``` <h2 align="center">Examples</h2> **schema.json** ```json { "type": "object", "properties": { "name": { "type": "string" }, "test": { "anyOf": [ { "type": "array" }, { "type": "string" }, { "instanceof": "RegExp" } ] }, "transform": { "instanceof": "Function" }, "sourceMap": { "type": "boolean" } }, "additionalProperties": false } ``` ### `Loader` ```js import { getOptions } from 'loader-utils' import validateOptions from 'schema-utils' import schema from 'path/to/schema.json' function loader (src, map) { const options = getOptions(this) || {} validateOptions(schema, options, 'Loader Name') // Code... } ``` ### `Plugin` ```js import validateOptions from 'schema-utils' import schema from 'path/to/schema.json' class Plugin { constructor (options) { validateOptions(schema, options, 'Plugin Name') this.options = options } apply (compiler) { // Code... } } ``` [npm]: https://img.shields.io/npm/v/schema-utils.svg [npm-url]: https://npmjs.com/package/schema-utils [node]: https://img.shields.io/node/v/schema-utils.svg [node-url]: https://nodejs.org [deps]: https://david-dm.org/webpack-contrib/schema-utils.svg [deps-url]: https://david-dm.org/webpack-contrib/schema-utils [test]: http://img.shields.io/travis/webpack-contrib/schema-utils.svg [test-url]: https://travis-ci.org/webpack-contrib/schema-utils [cover]: https://codecov.io/gh/webpack-contrib/schema-utils/branch/master/graph/badge.svg [cover-url]: https://codecov.io/gh/webpack-contrib/schema-utils [chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg [chat-url]: https://gitter.im/webpack/webpack