1616from collections import defaultdict
1717from enum import Enum
1818from pathlib import Path
19+ from textwrap import wrap
1920
2021import typer
2122from dotenv import load_dotenv
@@ -120,13 +121,20 @@ def _row_sort_key(row_value):
120121 except (TypeError , ValueError ):
121122 return (1 , str (row_value ))
122123
123- max_errors_to_show = 100
124+ max_errors_to_show = 1000
124125 shown = 0
126+ first_group = True
125127 for row in sorted (grouped_errors .keys (), key = _row_sort_key ):
126128 if shown >= max_errors_to_show :
127129 break
128130
129131 row_errors = grouped_errors [row ]
132+ if not first_group :
133+ typer .secho (
134+ " " + "-" * 56 ,
135+ fg = typer .colors .BRIGHT_BLACK ,
136+ )
137+ first_group = False
130138 typer .secho (
131139 f" Row { row } ({ len (row_errors )} issue{ 's' if len (row_errors ) != 1 else '' } )" ,
132140 fg = typer .colors .CYAN ,
@@ -138,11 +146,37 @@ def _row_sort_key(row_value):
138146 break
139147 field = err .get ("field" , "unknown" )
140148 message = err .get ("error" ) or err .get ("msg" ) or "validation error"
141- prefix = typer .style (" ! " , fg = typer .colors .BRIGHT_YELLOW )
142- field_part = f"\033 [1;38;5;208m{ field } :\033 [0m"
143- message_part = typer .style (f" { message } " , fg = typer .colors .BRIGHT_YELLOW )
144- typer .echo (f"{ prefix } { field_part } { message_part } " )
149+ input_value = err .get ("value" )
150+ prefix_raw = " ! "
151+ field_raw = f"{ field } :"
152+ msg_chunks = wrap (
153+ str (message ),
154+ width = max (20 , 200 - len (prefix_raw ) - len (field_raw ) - 1 ),
155+ ) or ["" ]
156+ prefix = typer .style (prefix_raw , fg = typer .colors .BRIGHT_YELLOW )
157+ field_part = f"\033 [1;38;5;208m{ field_raw } \033 [0m"
158+ first_msg_part = typer .style (
159+ msg_chunks [0 ], fg = typer .colors .BRIGHT_YELLOW
160+ )
161+ typer .echo (f"{ prefix } { field_part } { first_msg_part } " )
162+ msg_indent = " " * (len (prefix_raw ) + len (field_raw ) + 1 )
163+ for chunk in msg_chunks [1 :]:
164+ typer .secho (f"{ msg_indent } { chunk } " , fg = typer .colors .BRIGHT_YELLOW )
165+ if input_value is not None :
166+ input_prefix = " input="
167+ input_chunks = wrap (
168+ str (input_value ), width = max (20 , 200 - len (input_prefix ))
169+ ) or ["" ]
170+ typer .secho (
171+ f"{ input_prefix } { input_chunks [0 ]} " , fg = typer .colors .BRIGHT_WHITE
172+ )
173+ input_indent = " " * len (input_prefix )
174+ for chunk in input_chunks [1 :]:
175+ typer .secho (
176+ f"{ input_indent } { chunk } " , fg = typer .colors .BRIGHT_WHITE
177+ )
145178 shown += 1
179+ typer .echo ()
146180
147181 if len (validation_errors ) > shown :
148182 typer .secho (
@@ -208,11 +242,18 @@ def _row_sort_key(row_value):
208242
209243 max_errors_to_show = 100
210244 shown = 0
245+ first_group = True
211246 for row in sorted (grouped_errors .keys (), key = _row_sort_key ):
212247 if shown >= max_errors_to_show :
213248 break
214249
215250 row_errors = grouped_errors [row ]
251+ if not first_group :
252+ typer .secho (
253+ " " + "-" * 56 ,
254+ fg = typer .colors .BRIGHT_BLACK ,
255+ )
256+ first_group = False
216257 typer .secho (
217258 f" Row { row } ({ len (row_errors )} issue{ 's' if len (row_errors ) != 1 else '' } )" ,
218259 fg = typer .colors .CYAN ,
@@ -224,13 +265,39 @@ def _row_sort_key(row_value):
224265 break
225266 field = err .get ("field" , "unknown" )
226267 message = err .get ("error" ) or err .get ("msg" ) or "validation error"
227- prefix = typer .style (" ! " , fg = typer .colors .BRIGHT_YELLOW )
268+ input_value = err .get ("value" )
269+ prefix_raw = " ! "
270+ field_raw = f"{ field } :"
271+ msg_chunks = wrap (
272+ str (message ),
273+ width = max (20 , 200 - len (prefix_raw ) - len (field_raw ) - 1 ),
274+ ) or ["" ]
275+ prefix = typer .style (prefix_raw , fg = typer .colors .BRIGHT_YELLOW )
228276 field_part = typer .style (
229- f"{ field } :" , fg = typer .colors .BRIGHT_YELLOW , bold = True
277+ field_raw , fg = typer .colors .BRIGHT_YELLOW , bold = True
278+ )
279+ first_msg_part = typer .style (
280+ msg_chunks [0 ], fg = typer .colors .BRIGHT_YELLOW
230281 )
231- message_part = typer .style (f" { message } " , fg = typer .colors .BRIGHT_YELLOW )
232- typer .echo (f"{ prefix } { field_part } { message_part } " )
282+ typer .echo (f"{ prefix } { field_part } { first_msg_part } " )
283+ msg_indent = " " * (len (prefix_raw ) + len (field_raw ) + 1 )
284+ for chunk in msg_chunks [1 :]:
285+ typer .secho (f"{ msg_indent } { chunk } " , fg = typer .colors .BRIGHT_YELLOW )
286+ if input_value is not None :
287+ input_prefix = " input="
288+ input_chunks = wrap (
289+ str (input_value ), width = max (20 , 200 - len (input_prefix ))
290+ ) or ["" ]
291+ typer .secho (
292+ f"{ input_prefix } { input_chunks [0 ]} " , fg = typer .colors .BRIGHT_WHITE
293+ )
294+ input_indent = " " * len (input_prefix )
295+ for chunk in input_chunks [1 :]:
296+ typer .secho (
297+ f"{ input_indent } { chunk } " , fg = typer .colors .BRIGHT_WHITE
298+ )
233299 shown += 1
300+ typer .echo ()
234301
235302 if len (validation_errors ) > shown :
236303 typer .secho (
0 commit comments