@@ -308,6 +308,11 @@ export function validateApiConfigurationExcludingModelErrors(
308308 return undefined
309309}
310310
311+ /**
312+ * Validates the ArchGw preference configuration YAML
313+ * @param archgwPreferenceConfig The YAML string to validate
314+ * @returns An object with validation results: { isValid, errorMessage }
315+ */
311316export function validateArchGwPreferenceConfig ( archgwPreferenceConfig : string ) {
312317 try {
313318 // Only validate if not empty
@@ -316,19 +321,33 @@ export function validateArchGwPreferenceConfig(archgwPreferenceConfig: string) {
316321 if ( ! Array . isArray ( parsed ) ) {
317322 return {
318323 isValid : false ,
319- errorMessage : "YAML must be a list of objects with 'name', ' model' and 'usage' ." ,
324+ errorMessage : "YAML must be a list of objects, each with 'model' and 'routing_preferences' array ." ,
320325 }
321326 }
322327 for ( const item of parsed ) {
323- if (
324- typeof item !== "object" ||
325- typeof item . name !== "string" ||
326- typeof item . model !== "string" ||
327- typeof item . usage !== "string"
328- ) {
328+ if ( typeof item !== "object" || typeof item . model !== "string" ) {
329+ return {
330+ isValid : false ,
331+ errorMessage : "Each item must have a 'model' string field." ,
332+ }
333+ }
334+ if ( ! Array . isArray ( item . routing_preferences ) ) {
329335 return {
330336 isValid : false ,
331- errorMessage : "Each item must have 'name', 'model' and 'usage' as strings." ,
337+ errorMessage : "Each item must have a 'routing_preferences' array." ,
338+ }
339+ }
340+ for ( const pref of item . routing_preferences ) {
341+ if (
342+ typeof pref !== "object" ||
343+ typeof pref . name !== "string" ||
344+ typeof pref . description !== "string"
345+ ) {
346+ return {
347+ isValid : false ,
348+ errorMessage :
349+ "Each routing preference must be an object with 'name' and 'description' (both strings)." ,
350+ }
332351 }
333352 }
334353 }
0 commit comments