Skip to content

Commit

Permalink
fix postAdduser
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Apr 25, 2015
1 parent dd1171a commit 94e28d8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions examples/vibed-mongo/source/service.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ class MongoService
HTTPServerResponse res,
)
{
logInfo(text("MongoService: POST /adduser : ", username));

import vibe.utils.validation;
auto bson = Json.emptyObject;

logInfo(text("MongoService: POST /adduser : ", username));
enforce(age < 200 && age >= 0, "wrong age");

auto bson = Bson.emptyObject;
bson.username = validateUserName(username);
bson.email = email.validateEmail;
bson.email = validateEmail(email);
bson.fullname = fullname;
enforce(age < 200 && age >= 0, "wrong age");
bson.age = age;
bson.age = age;
bson.location = location;
bson.gender = gender.toLower;
bson.gender = gender.toLower;

collection.insert(bson);
res.writeBody("");
}
Expand Down

0 comments on commit 94e28d8

Please sign in to comment.