
Company News
Socket Joins the OpenJS Foundation
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.
@0x4447/pretzel
Advanced tools
We created our Pretzel recursive JSON data validation after realizing that there were no npm modules that could recursively validate a JSON object with multiple nested values objects.
We are aware of Validate.js, but as the author explains, the support for complete object is very basic. We did consider proposing a PR to the project, but the source code turned out to be too hard to rezone about. Thus, Pretzel was born.
The goal of this tool is not just to handle nested JSON files like this...
{
first_name: 'David',
last_name: 'Gatti',
age: 99,
address: {
street: 'Wonder Land',
nr: 55,
state: 'TX',
country: 'United States'
}
}
...with rules structured this way:
{
first_name: {
type: 'string'
},
last_name: {
regexp: '[a-zA-Z]'
},
age: {
type: 'number'
},
address: {
street: {
type: 'string'
},
nr: {
type: 'number'
},
state: {
includes: ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
},
country: {
includes: ['United States', 'Canada']
}
}
}
We also wanted to make the source code as simple to understand as possible. If you check the index.js file, you'll see what we mean. Use it, modify it, learn from it.
] npm install @0x4447/pretzel
] npm run test
let pretzel = require('pretzel');
let pretzel = require('pretzel');
//
// RULES
//
let rules = {
name: {
type: "string"
}
};
//
// Good DATA
//
let good_data = {
name: '0x4447'
};
//
// Bad DATA
//
let bad_data = {
name: 123321
};
//
// 1. Execute validation.
//
let good = pretzel(good_data, rules);
let bad = pretzel(bad_data, rules);
//
// 2. Check the validation result.
//
console.info(good);
console.info(bad);
Below is a list of all the rules the module supports at this time.
{
biggerThan: 5
}
{
smallerThan: 5
}
{
comparison: 1
}
{
includes: [9, '0x4447']
}
{
regexp: '[aAzZ.-]'
}
{
type: "string || number || object || array"
}
If you enjoyed this project, please consider giving it a 🌟. And check out our 0x4447 GitHub account, where we have additional resources that you might find useful or interesting.
This project is brought to you by 0x4447 LLC, a software company specializing in build custom solutions on top of AWS. Find out more by following this link: https://0x4447.com or, say hello@0x4447.email.
FAQs
🥨 Recursive JSON data validation.
The npm package @0x4447/pretzel receives a total of 0 weekly downloads. As such, @0x4447/pretzel popularity was classified as not popular.
We found that @0x4447/pretzel 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.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.