
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@de-formed/node-validations
Advanced tools
@De-Formed Validations offers a robust and unopinionated API to customize form and data validations. With only a handful of properties to learn, @de-formed maintains its own internal state with simple function calls so that you can design your architecture the way you want to.
yarn add @de-formed/node-validations
npm i @de-formed/node-validations
Validation Schemas are created by defining an object with keys that hold an array of validation rules. Each validation rule consists of the error message to provide if the rule fails, and a function that returns true or false.
// PersonValidation.js
import { Validation } from '@de-formed/node-validations';
export const PersonValidation = () => {
return Validation({
firstName: [
{
error: 'First Name is required.',
validation: ({ firstName }) => firstName.length > 0,
},
{
error: 'First Name cannot be longer than 20 characters.',
validation: ({ firstName }) => firstName.length <= 20,
},
],
lastName: [
{
error: 'Last Name is required.',
validation: ({ lastName }) => lastName.length > 0,
},
{
error: 'Last Name cannot be longer than 20 characters.',
validation: ({ lastName }) => lastName.length <= 20,
},
{
error: 'Must be Ross if fist name is Bob.',
validation: ({ firstName, lastName }) => {
return firstName === 'Bob' ? lastName === 'Ross' : true;
},
},
],
});
};
import { PersonValidation } from './PersonValidation';
import { Request, Response } from 'express';
const v = PersonValidation();
app.post('/person', (req: Request, res: Response) =>
v.validateAll(req.body) ? res.status(201) : res.json(v.validationState),
);
Check out the documentation.
More examples and CodeSandboxes.

This project is licensed under the terms of the MIT license.
FAQs
Modular, Function-driven Validations
The npm package @de-formed/node-validations receives a total of 4 weekly downloads. As such, @de-formed/node-validations popularity was classified as not popular.
We found that @de-formed/node-validations 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.