]> granicus.if.org Git - icinga2/commitdiff
Fix incorrect validator for strings
authorGunnar Beutner <gunnar@beutner.name>
Mon, 30 Mar 2015 12:55:41 +0000 (14:55 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 30 Mar 2015 12:58:42 +0000 (14:58 +0200)
fixes #8907

tools/mkclass/classcompiler.cpp

index 798ca25dc000a856edfc13d1ff3a0e56fa6a1394..1cd9b05148a6e6c9124267b41f285eee244e5a37 100644 (file)
@@ -721,7 +721,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string&
 
                if (fieldType.GetRealType() == "Value") {
                        if (rule.Type == "String")
-                               m_Impl << "\t\t" << "if (value.IsScalar())" << std::endl
+                               m_Impl << "\t\t" << "if (value.IsEmpty() || value.IsScalar())" << std::endl
                                       << "\t\t\t" << "return;" << std::endl;
                        else if (rule.Type == "Number") {
                                m_Impl << "\t\t" << "try {" << std::endl
@@ -829,14 +829,7 @@ void ClassCompiler::CodeGenValidator(const std::string& name, const std::string&
                               << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid attribute: \" + key));" << std::endl
                               << "\t" << "else" << std::endl;
 
-               m_Impl << (!static_known_attribute ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), boost::assign::list_of(";
-
-               if (validatorType == ValidatorField)
-                       m_Impl << "\"" << field << "\"";
-               else
-                       m_Impl << "key";
-
-               m_Impl << "), \"Invalid type.\"));" << std::endl;
+               m_Impl << (!static_known_attribute ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid type.\"));" << std::endl;
        }
 
        m_Impl << "}" << std::endl << std::endl;