# Validators Reference URL: /reference/validators Every built-in OpenHTF measurement validator — in_range, within_percent, equals, matches_regex, all_in_range, all_equals, dimension_pivot_validate, consistent_end_dimension_pivot_validate — with marginal limits, custom validators and how they appear in the record. A validator is a callable that takes the measured value and returns `True` (PASS) or `False` (FAIL). Built-ins live in `openhtf.util.validators` and are also exposed as chainable methods on `htf.Measurement` — `.in_range(0, 10)` is `.with_validator(validators.in_range(0, 10))`. A measurement may carry several validators; all must pass. Inclusive numeric range. Either bound may be omitted. `marginal_*` set inner limits that flag a passing value as marginal. `type` casts templated string arguments (`'{minimum}'` filled by `with_args`). Record string: `3.0 <= x <= 5.0`; with marginal limits `5 <= Marginal:9 <= x <= Marginal:11 <= 17`; `x == 5` when both bounds are equal. `expected ± percent %`. `within_percent(5.0, 2)` accepts 4.9–5.1. Record string: `'x' is within 2% of 5.0. Marginal: None% of 5.0`. Exact equality for numbers, strings, booleans. Record string: `'x' is equal to '5'`. `re.match` against a string value. Record string: `'x' matches /^1\.4/`. Any callable `value -> bool`. Define `__str__` on a class-based validator so the record shows something readable instead of `>`. Every element of a list value is within the range. Every element of a list value equals `value`. Apply a scalar validator to every stored value of a multi-dimensional measurement. Fails if any sample fails. This is the way to put limits on a monitor's time series. Record string: `All values pass: 0.3 <= x <= 0.5`. Like `dimension_pivot_validate`, but once a row passes every following row must pass — models a value that must settle and stay settled (a rail reaching regulation, a temperature reaching set point). Record string: `Once pass, rest must also pass: ...`. `in_range` and `within_percent` accept inner *marginal* bounds. A value between the marginal and hard limits passes but sets `marginal: true` on the measurement, phase and test, and the console banner shows `PASS (MARGINAL)`. Use it to catch drift before it becomes yield loss. Marginal → `.validate_on({DiagResult: validator})` swaps in a different validator when a diagnosis is present — for example a wider current limit in high-power mode. For anything reusable, subclass `ValidatorBase` and give it a `__str__`: Validators must be `deepcopy()`-able (phases are copied when templated with `with_args`), so avoid holding open file handles or sockets in them. Registering with `validators.register(Monotonic, name='monotonic')` additionally enables the method form `.monotonic()`. Validators are serialized with `str()`: Tools that parse limits back out of the record (including TofuPilot) rely on the built-in formats above — one more reason to prefer built-ins and readable `__str__` on custom ones.