Add column type mapping and enhance validation
Introduced a backend mapping for column expected types, improving validation and error handling. Updated UI to highlight default and corrected values, with additional detailed validation for data collection parameters.
This commit is contained in:
@ -163,24 +163,19 @@ class DataCollectionParameters(BaseModel):
|
||||
) from e
|
||||
return v
|
||||
|
||||
@field_validator("oscillation", "targetresolution", mode="before")
|
||||
@field_validator("oscillation", mode="before")
|
||||
@classmethod
|
||||
def positive_float_validator(cls, v):
|
||||
logger.debug(f"Running positive_float_validator for value: {v}")
|
||||
if v is not None:
|
||||
try:
|
||||
v = float(v)
|
||||
if v <= 0:
|
||||
logger.error(f"Validation failed: '{v}' is not greater than 0.")
|
||||
raise ValueError(
|
||||
f"'{v}' is not valid. Value must be a positive float."
|
||||
)
|
||||
except (ValueError, TypeError) as e:
|
||||
logger.error(f"Validation failed: '{v}' caused error {str(e)}")
|
||||
raise ValueError(
|
||||
f"'{v}' is not valid. Value must be a positive float."
|
||||
) from e
|
||||
logger.debug(f"Validation succeeded for value: {v}")
|
||||
if v is None:
|
||||
return None
|
||||
try:
|
||||
v = float(v)
|
||||
if v <= 0:
|
||||
raise ValueError(f"'{v}' is not valid. Value must be a positive float.")
|
||||
except (ValueError, TypeError) as e:
|
||||
raise ValueError(
|
||||
f"'{v}' is not valid. Value must be a positive float."
|
||||
) from e
|
||||
return v
|
||||
|
||||
@field_validator("exposure", mode="before")
|
||||
|
Reference in New Issue
Block a user