Skip to main content
Runpod’s validator utility ensures robust execution of serverless workers by validating input data against a defined schema. To use it, import the following to your Python file:
The validate function takes two arguments:
  • the input data
  • the schema to validate against

Schema Definition

Define your schema as a nested dictionary with these possible rules for each input:
  • required (default: False): Marks the type as required.
  • default (default: None): Default value if input is not provided.
  • type (required): Expected input type.
  • constraints (optional): for example, a lambda function returning true or false.

Example Usage

Testing

Save as your_handler.py and test using:
Or with inline input:
This approach allows early detection of input errors, preventing issues from unexpected or malformed inputs.