MCPcopy Create free account
hub / github.com/apple/axlearn / register_validator

Function register_validator

axlearn/common/config.py:298–306  ·  view source on GitHub ↗

Registers a custom config field validator. Args: match_fn: A function that returns True if the value should be validated by `validate_fn`. validate_fn: A function that raises `InvalidConfigValueError` if a value is not a valid config field value.

(*, match_fn: Callable[[Any], bool], validate_fn: Callable[[Any], None])

Source from the content-addressed store, hash-verified

296
297
298def register_validator(*, match_fn: Callable[[Any], bool], validate_fn: Callable[[Any], None]):
299 """Registers a custom config field validator.
300
301 Args:
302 match_fn: A function that returns True if the value should be validated by `validate_fn`.
303 validate_fn: A function that raises `InvalidConfigValueError` if a value is not a valid
304 config field value.
305 """
306 _config_field_validators[match_fn] = validate_fn
307
308
309def validate_config_field_name(name: str) -> None:

Callers 3

utils.pyFile · 0.90
config.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected