Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
cached-validations
Advanced tools
Create validation functions that cache results
$ npm install --save cached-validations
Create a validation schema and then you can create a validation function that takes in values and outputs any errors based on the passed validation functions.
If an error has already been returned for a specific value then it will be cached and returned on the next invocation, making this a relatively performant option for doing things like form validations on keyup
.
import createValidator from 'cached-validations';
const formValidations = {
email: email => {
if (!email) return 'Email is required';
if (isNotEmail(email)) return 'Must be a valid email';
},
age: age => {
if (!age) return 'Age is required';
if (age > 120 || age < 13) return 'Must provide a valid age.'
}
}
const formValidator = createValidator(formValidations);
const dummyInput = {
email: 'notanemail',
age: 44
}
const errors = formValidator(dummyInput)
// {email: 'Must be a valid email'}
createValidator(validations: object) => function => object
Takes an object mapping validation functions to keys, returns a function that will validate objects with those same keys and return any errors based on the initially provided validations.
MIT © Brandon Dail
FAQs
Easy and fast validations with cached results
The npm package cached-validations receives a total of 1 weekly downloads. As such, cached-validations popularity was classified as not popular.
We found that cached-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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.