Browse Source

change to map instead of vector

master
Jørgen Sverre Lien Sellæg 5 years ago
parent
commit
484fd31518
  1. 7
      src/data.cpp

7
src/data.cpp

@ -56,13 +56,14 @@ bool data::validate(const json &input) {
const std::string phone = input.value("phone", "");
const std::string email = input.value("email", "");
const std::vector<std::string> strings{name, address, phone, email};
const std::unordered_map<std::string, std::string> strings{
{"name", name}, {"address", address}, {"phone", phone}, {"email", email}};
for (const auto &f : strings) {
if (f.size() == 0) {
if (f.second.size() == 0) {
return false;
}
if (f.size() >= 255) {
if (f.second.size() >= 255) {
return false;
}
}

Loading…
Cancel
Save