std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
// "Action" features has no data, but still valid. e.g "Remove Part"
if (!aData->isValid()) {
+ if (!theFeature->isAction())
+ theError = "There is no data.";
return theFeature->isAction();
}
- if (!aData->isValid())
- return false;
const std::string kAllTypes = "";
std::list<std::string> aLtAttributes = aData->attributesIDs(kAllTypes);
std::list<std::string>::iterator it = aLtAttributes.begin();
myNotObligatory.find(theFeature->getKind());
if (aFeatureFind == myNotObligatory.end() || // and it is obligatory for filling
aFeatureFind->second.find(*it) == aFeatureFind->second.end()) {
+ theError = "Attribute \"" + anAttr->id() + "\" is not initialized.";
return false;
}
}
std::string& theError) const
{
AttributeStringPtr aStrAttr = std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
- bool result = isVariable(aStrAttr->value()) && isUnique(theAttribute, aStrAttr->value());
- return result;
+ if (!isVariable(aStrAttr->value())) {
+ theError = "Incorrect variable name.";
+ return false;
+ }
+ if (!isUnique(theAttribute, aStrAttr->value())) {
+ theError = "Variable name is not unique.";
+ return false;
+ }
+ return true;
}
bool ParametersPlugin_VariableValidator::isVariable(const std::string& theString) const
std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aFeature->firstResult());
AttributeStringPtr aStrAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
+ std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
bool isEmptyExpr = aStrAttr->value().empty();
- if(isEmptyExpr)
+ if(isEmptyExpr) {
+ theError = "Expression is empty.";
return false;
+ }
- if(!aParam.get())
+ if(!aParam.get()) {
+ theError = "Result is empty.";
return false;
+ }
+ theError = aFeature->error();
return aFeature->error().empty();
}