@@ -20,6 +20,7 @@ import com.embabel.agent.api.annotation.Agent
2020import com.embabel.agent.api.annotation.Condition
2121import com.embabel.agent.core.AgentScope
2222import com.embabel.common.core.validation.ValidationError
23+ import com.embabel.common.core.validation.ValidationErrorCodes
2324import com.embabel.common.core.validation.ValidationLocation
2425import com.embabel.common.core.validation.ValidationResult
2526import com.embabel.common.core.validation.ValidationSeverity
@@ -60,7 +61,7 @@ class DefaultAgentStructureValidator(
6061
6162 if (actionMethods.isEmpty() && conditionMethods.isEmpty() && ! hasGoals) {
6263 val error = ValidationError (
63- code = " EMPTY_AGENT_STRUCTURE" ,
64+ code = ValidationErrorCodes . EMPTY_AGENT_STRUCTURE ,
6465 message = " Agent class '${clazz.name} ' has no @Action or @Condition methods and no goals defined. This agent will NOT be registered!" ,
6566 severity = ValidationSeverity .ERROR ,
6667 location = ValidationLocation (
@@ -82,7 +83,7 @@ class DefaultAgentStructureValidator(
8283 if (agentScope.actions.isEmpty() && agentScope.conditions.isEmpty() && agentScope.goals.isEmpty()) {
8384 errors.add(
8485 ValidationError (
85- code = " EMPTY_AGENT_STRUCTURE" ,
86+ code = ValidationErrorCodes . EMPTY_AGENT_STRUCTURE ,
8687 message = " Agent '${agentScope.name} ' has no actions, conditions, or goals defined" ,
8788 severity = ValidationSeverity .ERROR ,
8889 location = ValidationLocation (
@@ -99,7 +100,7 @@ class DefaultAgentStructureValidator(
99100 if (agentScope.goals.isEmpty()) {
100101 errors.add(
101102 ValidationError (
102- code = " MISSING_GOALS" ,
103+ code = ValidationErrorCodes . MISSING_GOALS ,
103104 message = " Agent '${agentScope.name} ' must have at least one goal defined" ,
104105 severity = ValidationSeverity .ERROR ,
105106 location = ValidationLocation (
@@ -116,7 +117,7 @@ class DefaultAgentStructureValidator(
116117 agentScope.actions.groupBy { it.name }.filter { it.value.size > 1 }.forEach { (name, _) ->
117118 errors.add(
118119 ValidationError (
119- code = " DUPLICATE_ACTION_NAME" ,
120+ code = ValidationErrorCodes . DUPLICATE_ACTION_NAME ,
120121 message = " Agent '${agentScope.name} ' has more than one action named '$name '" ,
121122 severity = ValidationSeverity .ERROR ,
122123 location = ValidationLocation (
@@ -141,7 +142,7 @@ class DefaultAgentStructureValidator(
141142 if (preconditionsWithMultipleParams) {
142143 errors.add(
143144 ValidationError (
144- code = " INVALID_ACTION_SIGNATURE" ,
145+ code = ValidationErrorCodes . INVALID_ACTION_SIGNATURE ,
145146 message = " Action '${action.name} ' has preconditions with multiple parameters" ,
146147 severity = ValidationSeverity .ERROR ,
147148 location = ValidationLocation (
@@ -163,7 +164,7 @@ class DefaultAgentStructureValidator(
163164 if (method?.parameterCount ? : 0 > 1 ) {
164165 errors.add(
165166 ValidationError (
166- code = " INVALID_CONDITION_SIGNATURE" ,
167+ code = ValidationErrorCodes . INVALID_CONDITION_SIGNATURE ,
167168 message = " Condition '${condition.name} ' must have at most one parameter" ,
168169 severity = ValidationSeverity .ERROR ,
169170 location = ValidationLocation (
0 commit comments