lib: refactor validators
This makes sure our validator functions actually only validate and have no side effects. Please have a look at the individual commit messages for further details.
It is just a code cleanup and no behavior change.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines