Skip to content

Commit

Permalink
Merge 22030e7 into 86a8d61
Browse files Browse the repository at this point in the history
  • Loading branch information
gbenziv authored Dec 31, 2020
2 parents 86a8d61 + 22030e7 commit 5ab08c4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/domain/customermgmt/customermgmtcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CustomerManagementController::CustomerManagementController(
}

std::vector<entity::Customer> CustomerManagementController::list() {
LOG_DEBUG("Getting the list of products");
LOG_DEBUG("Getting the list of customers");
return mCachedList;
}

Expand All @@ -59,7 +59,7 @@ CUSTOMERMGMTAPISTATUS CustomerManagementController::save(const entity::Customer&
{
LOG_DEBUG("Validating fields");
entity::validator::PersonValidator validator(customer);
validationResult->insert(validator.result().begin(), validator.result().end());
validationResult->merge(validator.result());
}
if (!validationResult->empty()) {
LOG_WARN("Entity contains invalid data. Returning validation results.");
Expand Down
2 changes: 1 addition & 1 deletion core/domain/customermgmt/customermgmtcontroller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CustomerManagementController : public CustomerManagementControlInterface {

CustomerMgmtDataPtr mDataProvider;
CustomerMgmtViewPtr mView;
std::vector<entity::Customer> mCachedList; // List of products
std::vector<entity::Customer> mCachedList; // List of customers
};

} // namespace customermgmt
Expand Down
12 changes: 6 additions & 6 deletions core/domain/employeemgmt/employeecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ EMPLMGMTSTATUS EmployeeMgmtController::save(const SaveEmployeeData& employeeData
entity::validator::UserValidator validator(
entity::User("Proxy", "Proxy", employeeData.PIN,
"2020/10/10 10:10:10", "Proxy"));
employeeData.validationResult->insert(validator.result().begin(), validator.result().end());
employeeData.validationResult->merge(validator.result());
}
if (!employeeData.validationResult->empty()) {
LOG_WARN("Entity contains invalid data. Returning validation results.");
Expand Down Expand Up @@ -208,28 +208,28 @@ ValidationErrors EmployeeMgmtController::validateDetails(const entity::Employee&
// validate key employee data
{
entity::validator::EmployeeValidator validator(employee);
validationErrors.insert(validator.result().begin(), validator.result().end());
validationErrors.merge(validator.result());
}
// validate basic information
{
entity::validator::PersonValidator validator(employee);
validationErrors.insert(validator.result().begin(), validator.result().end());
validationErrors.merge(validator.result());
}
// validate address
{
entity::validator::AddressValidator validator(employee.address());
validationErrors.insert(validator.result().begin(), validator.result().end());
validationErrors.merge(validator.result());
}
// validate contact information
{
entity::validator::ContactDetailsValidator validator(employee.contactDetails());
validationErrors.insert(validator.result().begin(), validator.result().end());
validationErrors.merge(validator.result());
}
// validate ID
{
for (const entity::PersonalId& personalId : employee.personalIds()) {
entity::validator::PersonalIDValidator validator(personalId);
validationErrors.insert(validator.result().begin(), validator.result().end());
validationErrors.merge(validator.result());
}
}
return validationErrors;
Expand Down
2 changes: 1 addition & 1 deletion core/domain/inventory/inventorycontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ INVENTORYAPISTATUS InventoryController::save(const entity::Product& product,
{
LOG_DEBUG("Validating fields");
entity::validator::ProductValidator validator(product);
validationResult->insert(validator.result().begin(), validator.result().end());
validationResult->merge(validator.result());
}
if (!validationResult->empty()) {
LOG_WARN("Entity contains invalid data. Returning validation results.");
Expand Down
4 changes: 2 additions & 2 deletions core/validator/validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define CORE_VALIDATOR_VALIDATOR_HPP_
#include <functional>
#include <string>
#include <unordered_map>
#include <map>
#include <utility>
#include <vector>

Expand All @@ -38,7 +38,7 @@ enum ValidationStatus {
};

// map [field that failed, error message to display]
typedef std::unordered_map<std::string, std::string> Errors;
typedef std::map<std::string, std::string> Errors;

class Validator {
public:
Expand Down

0 comments on commit 5ab08c4

Please sign in to comment.