Skip to main content

Module validators

Module validators 

Source
Expand description

Composable request validators (plan #84).

Borrowed from MAX’s pipelines/core/context_validators.py. Each validation rule is a small composable function returning Result<(), ValidationError>. Pipelines pick which to apply for their request type.

Why composable instead of a single validate_request()?

  • Different request types (text embed, image embed, generation) share some rules (max length) but not others (image bounds).
  • Adding a rule = one function, not editing a monolith.
  • Easy to test rules in isolation.

Used by future serving paths (#31, #32 in PLAN.md). Today the benchmark runners can use it for input sanity checks.

Structs§

ChannelsAllowed
ImageContext
ImageMaxBounds
MaxBatchSize
MaxSeqLen
TextContext
Context fields a text request typically carries.
TokenIdsInVocab
ValidationError

Traits§

Validator
A single check on a context value.

Functions§

run_chain
Run a chain of validators; return the first error or Ok(()).

Type Aliases§

ValidationResult