- std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeatureIter =
- myAttrs.find(theFeature->getKind());
- if (aFeatureIter != myAttrs.cend()) {
- std::list<std::string> aLtAttributes = aData->attributesIDs(kAllTypes);
- std::list<std::string>::iterator anAttrIter = aLtAttributes.begin();
- for (; anAttrIter != aLtAttributes.end(); anAttrIter++) {
- const std::string& anAttributeID = *anAttrIter;
- std::map<std::string, AttrValidators>::const_iterator anAttr =
- aFeatureIter->second.find(anAttributeID);
- if (anAttr != aFeatureIter->second.end()) {
- // skip not-case attributres, that really may be invalid (issue 671)
- if (!const_cast<Model_ValidatorsFactory*>(this)->isCase(theFeature, anAttributeID))
- continue;
- AttrValidators::const_iterator aValIter = anAttr->second.cbegin();
- for (; aValIter != anAttr->second.cend(); aValIter++) {
- const std::string& aValidatorID = aValIter->first;
- const std::list<std::string>& anArguments = aValIter->second;
- std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = myIDs.find(aValidatorID);
- if (aFound == myIDs.end()) {
- Events_Error::send(std::string("Validator ") + aValidatorID + " was not registered");
- } else {
- const ModelAPI_AttributeValidator* anAttrValidator =
- dynamic_cast<const ModelAPI_AttributeValidator*>(aFound->second);
- if (anAttrValidator) {
- AttributePtr anAttribute = theFeature->data()->attribute(anAttributeID);
- std::string anError;
- if (!anAttrValidator->isValid(anAttribute, anArguments, anError)) {
- if (anError.empty())
- anError = "Unknown error.";
- theFeature->setAttributeValidationError(anAttributeID, aValidatorID, anError);
- return false;
- } else {
- theFeature->setAttributeValidationError(anAttributeID, aValidatorID, "");
- }
- }
- }
- }
+ std::list<std::string> aLtAttributes = aData->attributesIDs(kAllTypes);
+ std::list<std::string>::const_iterator anAttrIt = aLtAttributes.cbegin();
+ for (; anAttrIt != aLtAttributes.cend(); anAttrIt++) {
+ const std::string& anAttributeID = *anAttrIt;
+ AttributePtr anAttribute = theFeature->data()->attribute(anAttributeID);
+
+ std::string aValidatorID;
+ Events_InfoMessage anError;
+ if (!validate(anAttribute, aValidatorID, anError)) {
+ if (anError.empty())
+ anError = "Unknown error.";
+ if (anError.context().empty()) {
+ anError.setContext(theFeature->getKind() + ":" + anAttributeID + ":" + aValidatorID);