File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { z } from "zod" ;
2
2
import { ModelProviderName , Clients } from "./types" ;
3
+ import elizaLogger from "./logger" ;
3
4
4
5
// TODO: TO COMPLETE
5
6
export const envSchema = z . object ( {
@@ -137,11 +138,26 @@ export function validateCharacterConfig(json: unknown): CharacterConfig {
137
138
return CharacterSchema . parse ( json ) ;
138
139
} catch ( error ) {
139
140
if ( error instanceof z . ZodError ) {
140
- const errorMessages = error . errors
141
- . map ( ( err ) => `${ err . path . join ( "." ) } : ${ err . message } ` )
142
- . join ( "\n" ) ;
141
+ const groupedErrors = error . errors . reduce (
142
+ ( acc , err ) => {
143
+ const path = err . path . join ( "." ) ;
144
+ if ( ! acc [ path ] ) {
145
+ acc [ path ] = [ ] ;
146
+ }
147
+ acc [ path ] . push ( err . message ) ;
148
+ return acc ;
149
+ } ,
150
+ { } as Record < string , string [ ] >
151
+ ) ;
152
+
153
+ Object . entries ( groupedErrors ) . forEach ( ( [ field , messages ] ) => {
154
+ elizaLogger . error (
155
+ `Validation errors in ${ field } : ${ messages . join ( " - " ) } `
156
+ ) ;
157
+ } ) ;
158
+
143
159
throw new Error (
144
- ` Character configuration validation failed:\n ${ errorMessages } `
160
+ " Character configuration validation failed. Check logs for details."
145
161
) ;
146
162
}
147
163
throw error ;
You can’t perform that action at this time.
0 commit comments