Closed AlexZeitler closed 8 years ago
BTW if I clone the checkit repository from here and run the tests, everything is fine... :worried:
Found the solution:
var checkit = new Checkit({
firstName: 'required',
lastName: 'required',
email: ['required', 'email']
});
var body = {
firstName: 'Tim',
lastName: 'Griesser',
githubUsername: 'tgriesser'
};
checkit.run(body).then(function (validated) {
console.log(validated);
}).catch(err => {
console.log(err.toJSON());
});
The difference is in the .catch()
statement:
Sample from website: .catch(Checkit.Error, function(err) {})
Tests / working solution: .catch(function(err) {})
I like checkit pretty much, but I can't get it working using the async call in version 0.7.0 working (Node.js 6.2.2).
This is my test code:
This is the console output:
As you can see, there is a global Promise and the sync version works as expected but the async version doesn't throw.
If I pass in a valid object,
validated
is passed in and the console looks likeasync: { name: 'alex' }