summaryrefslogtreecommitdiff
path: root/src/components/smart_objects/src/string_schema_item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/smart_objects/src/string_schema_item.cc')
-rw-r--r--src/components/smart_objects/src/string_schema_item.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc
index 3fac3a6cde..1e4c8372f0 100644
--- a/src/components/smart_objects/src/string_schema_item.cc
+++ b/src/components/smart_objects/src/string_schema_item.cc
@@ -46,7 +46,18 @@ utils::SharedPtr<CStringSchemaItem> CStringSchemaItem::create(
}
Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
+}
+
+Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
+ rpc::ValidationReport* report__) {
if (SmartType_String != Object.getType()) {
+ std::string validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(SmartType_String) +
+ ", got: " +
+ SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
@@ -54,9 +65,19 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
size_t length;
if (mMinLength.getValue(length) && (value.size() < length)) {
+ std::stringstream stream;
+ stream << "Got string of size: " << value.size()
+ << ", minimum allowed: " << length;
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
if (mMaxLength.getValue(length) && (value.size() > length)) {
+ std::stringstream stream;
+ stream << "Got string of size: " << value.size()
+ << ", maximum allowed: " << length;
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
return Errors::OK;