
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@bleskomat/form
Advanced tools
Form class for node.js with validation (synchronous and asynchronous), post-processing, and support for handlebars templates.
Form class for node.js with validation (synchronous and asynchronous), post-processing, and support for handlebars templates.
Add to your application via npm
:
npm install @bleskomat/form
To use with express-handlebars:
const bodyParser = require('body-parser');
const express = require('express');
const Form = require('@bleskomat/form');
const Handlebars = require('express-handlebars');
const path = require('path');
const { ValidationError } = Form;
const app = express();
const hbs = Handlebars.create({
extname: '.html',
helpers: Form.handlebars.helpers,
partialsDir: [
path.join(__dirname, 'views', 'partials'),
Form.handlebars.partialsDir,
],
});
app.engine('.html', hbs.engine);
app.set('view engine', '.html');
app.set('views', path.join(__dirname, 'views'));
app.enable('view cache');
// Parse application/x-www-form-urlencoded:
app.use(bodyParser.urlencoded({ extended: false }));
const form = new Form({
title: 'Form partial example',
action: '/form',
groups: [
{
name: 'login',
inputs: [
{
name: 'username',
label: 'Username',
required: true,
validate: function(value, data) {
// `value` contains the value submitted for this field.
// `data` is an object which contains all form data.
// Perform custom validations for this field here.
// Throw an error here to fail the validation.
// Optionally return an instance of Promise to perform asynchronous validation.
},
process: function(value) {
// `value` contains the value submitted for this field.
// Perform custom processing for this field's value.
return value;
},
},
{
name: 'password',
label: 'Password',
required: true,
},
],
},
],
});
app.get('/form', function(req, res, next) {
res.render('form', {
form: form.serialize(),
});
});
app.post('/form', function(req, res, next) {
// `req.body` is provided by the `bodyParser` middleware.
form.validate(req.body).then(values => {
// Validation successful.
// `values` is an object which contains processed form data.
}).catch(error => {
if (error instanceof ValidationError) {
res.status(400);
} else {
error = new Error('An unexpected error has occurred');
res.status(500);
}
res.render('form', {
form: form.serialize({
errors: [ error.message ],
}),
});
});
});
Run automated tests as follows:
npm test
See CHANGELOG.md
This software is MIT licensed:
A short, permissive software license. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source. There are many variations of this license in use.
FAQs
Form class for node.js with validation (synchronous and asynchronous), post-processing, and support for handlebars templates.
The npm package @bleskomat/form receives a total of 1,071 weekly downloads. As such, @bleskomat/form popularity was classified as popular.
We found that @bleskomat/form demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.