Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
cruks-lib-config
Advanced tools
If you want to maintain and validate configuration objects with ease, then you are looking for cruks-lib-config!
How often you need to cope with situations like this?
function init(config) {
myOption || (myOption = parseInt(config.myOption, 10));
(...)
TypeError: Cannot read property 'myOption' of null
// NO MORE !!!
Wouldn't it be easier to keep all your configuration schemas in one place and delegate all the validation hassle to external library (like cruks-lib-config)?
var expectedConfiguration = expect.schema({
"myOption": expect.integer().default(10)
});
function init(config) {
config = expectedConfiguration.assert(config);
config.myOption; // 10! Much better!
}
Configuration processor asserts that any input matches your expected parameters and makes validating complicated objects much easier. It also provides some basic assertion tools and verbose debug messages.
Focus on clear, readable messages and ability to track exact failing element makes cruks-lib-config really special.
Every array item needs to be integer.
expect.array.every(expect.integer()).assert([1, "2", 3]);
Result:
AssertionFailureError: expected integer but "1" got (string)"2"
// "1" is the name of affected array key
expect = require("cruks-lib-config").expect;
expectedConfiguration = exepct.schema({
"a": expect.number(),
"b": expect.string(),
"c": expect.schema({
"d": expect.schema({
"e": expect.boolean()
})
}),
"f": expect.array()
});
expectedConfiguration.assert({
"a": 5,
"b": "some-string",
"c": {
"d": {
"e": "not-a-boolean"
}
},
"f": []
});
Result:
AssertionFailureError: expected boolean but "c.d.e" got (string)"not-a-boolean"
For more information please refer to project's wiki.
FAQs
If you want to maintain and validate configuration objects with ease, then you are looking for cruks-lib-config!
The npm package cruks-lib-config receives a total of 26 weekly downloads. As such, cruks-lib-config popularity was classified as not popular.
We found that cruks-lib-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.