mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-28 11:35:59 +08:00
Typo && Spacing
There was an extraneous space. I also updated functions syntax to follow the style guide referenced in other parts of this document. These functions could potentially be updated to es6 as well.
This commit is contained in:
@ -17,8 +17,7 @@ var memberSchema = Joi.object().keys({
|
||||
email: Joi.string().email()
|
||||
});
|
||||
|
||||
function addNewMember(newMember)
|
||||
{
|
||||
function addNewMember(newMember) {
|
||||
// assertions come first
|
||||
Joi.assert(newMember, memberSchema); //throws if validation fails
|
||||
// other logic here
|
||||
@ -29,12 +28,12 @@ function addNewMember(newMember)
|
||||
### Anti-pattern: no validation yields nasty bugs
|
||||
|
||||
```javascript
|
||||
// if the discount is positive let's then redirect the user to pring his discount coupons
|
||||
// if the discount is positive let's then redirect the user to print his discount coupons
|
||||
function redirectToPrintDiscount(httpResponse, member, discount)
|
||||
{
|
||||
if(discount != 0)
|
||||
if (discount != 0) {
|
||||
httpResponse.redirect(`/discountPrintView/${member.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
redirectToPrintDiscount(httpResponse, someMember);
|
||||
// forgot to pass the parameter discount, why the heck was the user redirected to the discount screen?
|
||||
|
||||
Reference in New Issue
Block a user