Gathering detailed insights and metrics for @develar/schema-utils
Gathering detailed insights and metrics for @develar/schema-utils
Gathering detailed insights and metrics for @develar/schema-utils
Gathering detailed insights and metrics for @develar/schema-utils
npm install @develar/schema-utils
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (99.9%)
Shell (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
250 Stars
200 Commits
39 Forks
10 Watchers
3 Branches
88 Contributors
Updated on Jun 26, 2025
Latest Version
2.6.5
Package Id
@develar/schema-utils@2.6.5
Unpacked Size
70.55 kB
Size
15.36 kB
File Count
14
NPM Version
6.13.4
Node Version
12.16.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
24
Package for validate options in loaders and plugins.
To begin, you'll need to install schema-utils
:
1npm install schema-utils
schema.json
1{ 2 "type": "object", 3 "properties": { 4 "option": { 5 "type": ["boolean"] 6 } 7 }, 8 "additionalProperties": false 9}
1import schema from './path/to/schema.json'; 2import validate from 'schema-utils'; 3 4const options = { option: true }; 5const configuration = { name: 'Loader Name/Plugin Name/Name' }; 6 7validate(schema, options, configuration);
schema
Type: String
JSON schema.
Simple example of schema:
1{ 2 "type": "object", 3 "properties": { 4 "name": { 5 "description": "This is description of option.", 6 "type": "string" 7 } 8 }, 9 "additionalProperties": false 10}
options
Type: Object
Object with options.
1validate( 2 schema, 3 { 4 name: 123, 5 }, 6 { name: 'MyPlugin' } 7);
configuration
Allow to configure validator.
There is an alternative method to configure the name
andbaseDataPath
options via the title
property in the schema.
For example:
1{ 2 "title": "My Loader options", 3 "type": "object", 4 "properties": { 5 "name": { 6 "description": "This is description of option.", 7 "type": "string" 8 } 9 }, 10 "additionalProperties": false 11}
The last word used for the baseDataPath
option, other words used for the name
option.
Based on the example above the name
option equals My Loader
, the baseDataPath
option equals options
.
name
Type: Object
Default: "Object"
Allow to setup name in validation errors.
1validate(schema, options, { name: 'MyPlugin' });
1Invalid configuration object. MyPlugin has been initialised using a configuration object that does not match the API schema. 2 - configuration.optionName should be a integer.
baseDataPath
Type: String
Default: "configuration"
Allow to setup base data path in validation errors.
1validate(schema, options, { name: 'MyPlugin', baseDataPath: 'options' });
1Invalid options object. MyPlugin has been initialised using an options object that does not match the API schema. 2 - options.optionName should be a integer.
postFormatter
Type: Function
Default: undefined
Allow to reformat errors.
1validate(schema, options, { 2 name: 'MyPlugin', 3 postFormatter: (formattedError, error) => { 4 if (error.keyword === 'type') { 5 return `${formattedError}\nAdditional Information.`; 6 } 7 8 return formattedError; 9 }, 10});
1Invalid options object. MyPlugin has been initialized using an options object that does not match the API schema. 2 - options.optionName should be a integer. 3 Additional Information.
schema.json
1{ 2 "type": "object", 3 "properties": { 4 "name": { 5 "type": "string" 6 }, 7 "test": { 8 "anyOf": [ 9 { "type": "array" }, 10 { "type": "string" }, 11 { "instanceof": "RegExp" } 12 ] 13 }, 14 "transform": { 15 "instanceof": "Function" 16 }, 17 "sourceMap": { 18 "type": "boolean" 19 } 20 }, 21 "additionalProperties": false 22}
Loader
1import { getOptions } from 'loader-utils'; 2import validateOptions from 'schema-utils'; 3 4import schema from 'path/to/schema.json'; 5 6function loader(src, map) { 7 const options = getOptions(this) || {}; 8 9 validateOptions(schema, options, { 10 name: 'Loader Name', 11 baseDataPath: 'options', 12 }); 13 14 // Code... 15} 16 17export default loader;
Plugin
1import validateOptions from 'schema-utils'; 2 3import schema from 'path/to/schema.json'; 4 5class Plugin { 6 constructor(options) { 7 validateOptions(schema, options, { 8 name: 'Plugin Name', 9 baseDataPath: 'options', 10 }); 11 12 this.options = options; 13 } 14 15 apply(compiler) { 16 // Code... 17 } 18} 19 20export default Plugin;
Please take a moment to read our contributing guidelines if you haven't yet done so.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
7 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/24 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More