
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
basicschema
Advanced tools
Module for easily creating and managing simple JS objects as schemas that can be used for general purpose.
See usage section for notes on how to implement the project on a live system.
The module can be used in both Node.js and frontend JS projects.
To get the package, simply run the following commands from terminal in your project directory:
Using npm
npm install basicschema --save
Using yarn
yarn add basicschema
The module can be used by first requiring the module in a project file and then crating a schema as follows:
example.js
const BasicSchema = require('basicschema');
const exampleSchema = new BasicSchema({
name: {
value: 'Jhon'
},
surname: {
value: 'Doe'
},
age: {
value: 32
}
});
Once a schema has been created as above, there are five built-in functions that can be used.
model Returns the schema objec, for example:
console.log( exampleSchema.model );
// Result
{
name: {
value: 'Jhon'
},
surname: {
value: 'Doe'
},
age: {
value: 32
}
}
getFieldNames Returns an array containing the names of all the fields.
console.log( exampleSchema.getFieldNames );
// Result
['name', 'surname', 'age']
getField(field) Returns the value of a specific field.
console.log( exampleSchema.getField('name') );
// Result
'Jhon'
setField(field, value) Sets the value of a specific field
exampleSchema.setField('name', 'Jane')
console.log( exampleSchema.model );
// Result
{
name: {
value: 'Jane'
},
surname: {
value: 'Doe'
},
age: {
value: 32
}
}
reset(emptyValue) Clears all the field values in the schema and inserts a plaseholder (usually null or '')
exampleSchema.reset(null);
console.log( exampleSchema.model );
// Result - using null => exampleSchema.reset(null);
{
name: {
value: null
},
surname: {
value: null
},
age: {
value: null
}
}
// Result - using '' => exampleSchema.reset('');
{
name: {
value: ''
},
surname: {
value: ''
},
age: {
value: ''
}
}
As the module has been built using an ES6 class (see github), it can easily be further extended as required.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
Simple module for creating basic JS object schemas.
We found that basicschema 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.