New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
have #3
Comments
Nice suggestion, noted down. It's a good competition for |
Not exactly. nopt is about command line arguments where have is to validate function arguments. A lot of bugs come down to passing the wrong type of argument and have is useful for validation. |
Yup. |
@stdarg I was pawing at it: have.assert(function(cond, message) {
if (!cond) {
console.log('WARN: assertion failed: ' + message);
}
}); In the above method is there way to say which method it was validating the arguments for? Say like |
It's implicit. The general use case of have is to check arguments for a function, e.g.:
In the above example, have would throw if
Though in the above case, we check the arguments object, it could be used to check any object. Another good use would be to validate documents returned from MongoDB or the JSON body of an HTTP request. I find it a super-handy module. |
Was having the discussion with author and he suggested something similar |
Fixed in http://nmotw.in/have thanks! |
a nice arg checking module
The text was updated successfully, but these errors were encountered: