added script to generate open api scheme automatically - execute with npm run watch:openapi
This commit is contained in:
@ -79,17 +79,20 @@ async def validate_cell(data: dict):
|
||||
|
||||
importer = SampleSpreadsheetImporter()
|
||||
|
||||
# Determine the expected type based on column name
|
||||
# Ensure we've cleaned the value before validation
|
||||
expected_type = importer.get_expected_type(col_name)
|
||||
|
||||
# Clean and validate the cell value
|
||||
cleaned_value = importer._clean_value(value, expected_type)
|
||||
|
||||
logger.info(f"Validating cell: row {row_num}, column {col_name}, value {cleaned_value}")
|
||||
|
||||
try:
|
||||
# Validate the cleaned value using the SpreadsheetModel (Pydantic validation)
|
||||
SpreadsheetModel(**{col_name: cleaned_value})
|
||||
# Construct a dictionary with the expected format for validation
|
||||
validation_data = {col_name: cleaned_value}
|
||||
SpreadsheetModel(**validation_data)
|
||||
logger.info(f"Validation succeeded for row {row_num}, column {col_name}")
|
||||
return {"is_valid": True, "message": ""}
|
||||
except ValidationError as e:
|
||||
# If validation fails, return the first error message
|
||||
# Extract the first error message
|
||||
message = e.errors()[0]['msg']
|
||||
logger.error(f"Validation failed for row {row_num}, column {col_name}: {message}")
|
||||
return {"is_valid": False, "message": message}
|
Reference in New Issue
Block a user