Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
The FieldVal-JS library allows you to easily validate objects and provide readable and structured error reports.
//Import FieldVal and FieldVal-BasicVal (some simple checks)
var FieldVal = require('fieldval');
var bval = require('fieldval-basicval');
//Have some data to validate
var data = {
my_integer: "clearly not an integer"
}
//Create a FieldVal instance using the data
var validator = new FieldVal(data);
//Get values using validator.get(field_name, field_type, required)
var my_integer = validator.get("my_integer", bval.integer(true));
//Log the result of the validation (null if no errors)
console.log(validator.end());
Output:
{
"invalid": {
"my_integer": {
"error_message": "Incorrect field type. Expected integer.",
"error": 2,
"expected": "integer",
"received": "string"
}
},
"error_message": "One or more errors.",
"error": 0
}
validator.get("my_integer", bval.integer(true))
checks that the value is an integer and indicates that it is required (true
).
validator.get("my_integer", bval.integer(true), bval.minimum(42))
now also checks that the integer is at least 42
. You can add as many checks as you like from here, or just write your own - they're just functions that return errors.
FieldVal-JS (This repository)
The core of FieldVal - provides basic validation functionality such as getting keys from an object and allows chaining of checks.
Basic checks and errors for required fields, type checking, length and numeric rules.
FieldVal-UI
A companion library that creates customizable forms that parse and display FieldVal error structures.
To install the node packages, run:
npm install fieldval
npm install fieldval-basicval
The FieldVal library works both as a node package and via the browser. To install the node packages, run:
bower install fieldval
bower install fieldval-basicval
To use in the browser, download and include the fieldval.js
file from this repository and fieldval-basicval.js
from https://github.com/FieldVal/fieldval-basicval-js/.
This project uses gulp.js to build and mocha to test.
npm install
gulp js
mocha test/test
FAQs
fieldval
The npm package fieldval receives a total of 0 weekly downloads. As such, fieldval popularity was classified as not popular.
We found that fieldval 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.