Input Validation#
Overview#
pychum validates input at dataclass construction time using __post_init__
methods. Validation is inline – the _validators.py file exists as an
empty placeholder for future extraction.
Validation Approach#
All validation happens when a dataclass is instantiated. Invalid values raise
ValueError immediately, before any rendering occurs. This catches
configuration errors at load time rather than producing malformed input files.
Validated Fields#
Atom#
Condition |
Error |
|---|---|
|
“Atom symbol is required unless it’s a point charge.” |
When point_charge is set, symbol is forced to "Q" (no error).
OptimSettings#
Field |
Allowed values |
|---|---|
|
LBFGS, VPO, FIRE |
Comparison is case-insensitive (.upper()).
ReparamSettings#
Field |
Allowed values |
|---|---|
|
linear, cubic |
Comparison is case-insensitive (.lower()).
FreeEndSettings#
Field |
Allowed values |
|---|---|
|
PERP, CONTOUR, FULL |
Comparison is case-insensitive (.upper()).
ZoomSettings#
Field |
Allowed values |
|---|---|
|
linear, cubic |
Comparison is case-insensitive (.lower()).
SpringSettings#
Field |
Allowed values |
|---|---|
|
image, dof, ideal |
|
no, cos, tan, cosTan, DNEB |
Both comparisons are case-insensitive (.lower()).
NebBlock#
Field |
Allowed values |
|---|---|
|
all, cionly |
|
no, startonly, always |
|
improved, original |
|
IDPP, LINEAR, XTB1TS, XTB1, XTB2TS, XTB2 |
convtype, quatern, and tangent use .lower(). interpolation uses
.upper().
RestartSettings#
Condition |
Error |
|---|---|
Both |
“Only one of gbwbasenameor allxyz should be provided.” |
TSGuessSettings#
Condition |
Error |
|---|---|
Both |
“Only one of xyzstructor pdbstructshould be provided.” |
Unvalidated Fields#
Most numeric fields (tolerances, step sizes, spring constants) accept any
value without range checking. Boolean fields are not validated. The
ConfigLoader relies on TOML parsing to enforce basic type correctness.
Template-level Validation#
The geom_scan.jinja template has an additional guard: if the total number
of scan coordinates (bonds + angles + dihedrals) exceeds 3, it emits an
error message instead of rendering the scan block. This is a template-level
check, not a dataclass validator.
Future Work#
The empty _validators.py and _orcablocks.py placeholders suggest planned
extraction of validation logic into dedicated modules. Currently all
validation is co-located with the dataclass definitions.