diff options
Diffstat (limited to 'src/components/smart_objects/src/array_schema_item.cc')
-rw-r--r-- | src/components/smart_objects/src/array_schema_item.cc | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc index 99d0a89252..dca0a815e0 100644 --- a/src/components/smart_objects/src/array_schema_item.cc +++ b/src/components/smart_objects/src/array_schema_item.cc @@ -42,48 +42,45 @@ utils::SharedPtr<CArraySchemaItem> CArraySchemaItem::create( } Errors::eType CArraySchemaItem::validate(const SmartObject& Object) { - std::string errorMessage; - return validate(Object, errorMessage); + rpc::ValidationReport report("RPC"); + return validate(Object, &report); } Errors::eType CArraySchemaItem::validate(const SmartObject& Object, - std::string& errorMessage) { + rpc::ValidationReport* report__) { if (SmartType_Array != Object.getType()) { - if (!Object.getKey().empty()) { - errorMessage.assign("Validation failed for " + Object.getKey() + ". "); - } - errorMessage += "Incorrect type, expected: " + - SmartObject::typeToString(SmartType_Array) + ", got: " + - SmartObject::typeToString(Object.getType()); + std::string validation_info = "Incorrect type, expected: " + + SmartObject::typeToString(SmartType_Array) + + ", got: " + + SmartObject::typeToString(Object.getType()); + report__->set_validation_info(validation_info); return Errors::INVALID_VALUE; } size_t sizeLimit; const size_t array_len = Object.length(); if (mMinSize.getValue(sizeLimit) && (array_len < sizeLimit)) { - if (!Object.getKey().empty()) { - errorMessage.assign("Validation failed for " + Object.getKey() + ". "); - } std::stringstream stream; stream << "Got array of size: " << array_len << ", minimum allowed: " << sizeLimit; - errorMessage += stream.str(); + std::string validation_info = stream.str(); + report__->set_validation_info(validation_info); return Errors::OUT_OF_RANGE; } if (mMaxSize.getValue(sizeLimit) && (array_len > sizeLimit)) { - if (!Object.getKey().empty()) { - errorMessage.assign("Validation failed for " + Object.getKey() + ". "); - } std::stringstream stream; stream << "Got array of size: " << array_len << ", maximum allowed: " << sizeLimit; - errorMessage += stream.str(); + std::string validation_info = stream.str(); + report__->set_validation_info(validation_info); return Errors::OUT_OF_RANGE; } for (size_t i = 0u; i < array_len; ++i) { - const Errors::eType result = - mElementSchemaItem->validate(Object.getElement(i), errorMessage); + std::stringstream strVal; + strVal << i; + const Errors::eType result = mElementSchemaItem->validate( + Object.getElement(i), &report__->ReportSubobject(strVal.str())); if (Errors::OK != result) { return result; } |