Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
IMPORTANT: Anchor is under active development! Please follow/star and keep up to date as the project develops. If you're interested in contributing, drop me a note at @mikermcneil. I welcome your feedback, ideas, and pull requests :)
Anchor is a javascript library that lets you define strict types. It also helps you validate and normalize the usage of command line scripts and even individual functions.
This makes it really useful for things like:
Adds support for strongly typed arguments, like http://lea.verou.me/2011/05/strongly-typed-javascript/, but goes a step further by adding support for array and object sub-validation. It's also the core validation library for the Sails ecosystem.
(Built on top of the great work with https://github.com/chriso/node-validator)
<script type='text/javscript' src="/js/anchor.js"></script>
npm install anchor
var anchor = require('anchor');
var userData = 'some string';
// This will guarantee that userData is a string
// If it's not, an error will be thrown
userData = anchor(userData).to('string');
// If you want to handle the error instead of throwing it, use a callback
anchor('something').to("string", function (err) {
// Err is an error object with a subset of the original data that didn't pass
// Specifying a callback will prevent an error from being thrown
});
// Limit data to match these requirements
var requirements = anchor({
name: 'string',
avatar: {
path: 'string'
name: 'string',
size: 'int',
type: 'string'
}
});
// Unvalidated data from the user
var userData = {
name: 'Elvis',
avatar: {
path: '/tmp/2Gf8ahagjg42.jpg',
name: '2Gf8ahagjg42.jpg',
size: 382944
type: 'image/jpeg'
}
};
// Verify that the userData at least contains your requirements
// It can have EXTRA keys, but it MUST have the keys you specify
anchor(userData).to(requirements);
npm test
Anchor was developed by @mikermcneil and is supported by Balderdash Co (@balderdashy). Hopefully, it makes your life a little bit easier!
Copyright © 2012-2013 Mike McNeil
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
High-level validation library for Node.js (used in Waterline)
The npm package anchor receives a total of 64,713 weekly downloads. As such, anchor popularity was classified as popular.
We found that anchor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.