1717def validate (
1818 file_path : str = typer .Argument (..., help = "Path to input file" ),
1919 rules : str | None = typer .Option (
20- None , "--rules" , help = "Validation rules (format: col:type or col:type:min-max or col:pattern or col:required or col:unique)"
20+ None ,
21+ "--rules" ,
22+ help = "Validation rules (format: col:type or col:type:min-max or col:pattern or col:required or col:unique)" ,
2123 ),
2224 rules_file : str | None = typer .Option (
2325 None , "--rules-file" , help = "JSON file with validation rules"
@@ -274,7 +276,7 @@ def validate(
274276 if not rules_list :
275277 typer .echo (
276278 "Error: No validation rules specified. Use --rules, --columns, --types, --range, --unique, or --null-threshold" ,
277- err = True
279+ err = True ,
278280 )
279281 typer .echo ("Run 'xl validate --help' for examples" )
280282 raise typer .Exit (1 )
@@ -292,9 +294,7 @@ def validate(
292294 if email_columns :
293295 import re
294296
295- email_pattern = re .compile (
296- r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
297- )
297+ email_pattern = re .compile (r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" )
298298
299299 for email_col in email_columns :
300300 if email_col not in df .columns :
@@ -305,9 +305,7 @@ def validate(
305305 if pd .notna (value ):
306306 value_str = str (value ).strip ()
307307 if value_str and not email_pattern .match (value_str ):
308- invalid_emails .append (
309- {"row" : idx , "value" : value_str }
310- )
308+ invalid_emails .append ({"row" : idx , "value" : value_str })
311309
312310 if invalid_emails :
313311 # Add email pattern errors to the report
@@ -365,7 +363,8 @@ def validate(
365363 # Only exit with code 1 if there are actual critical errors (not just type mismatches)
366364 # Type mismatches (column_type) are considered warnings for data quality validation
367365 critical_errors = [
368- e for e in report .errors
366+ e
367+ for e in report .errors
369368 if e .get ("type" ) != "column_type" # Filter out type mismatches, keep pattern errors
370369 ]
371370 if critical_errors :
0 commit comments