Input Validation Logic
Input Validation Overview
To ensure the reliability of AI evaluations and platform stability, the testing-api enforces strict validation on all incoming request payloads. Requests that fail validation will return a 400 Bad Request status code with a detailed error report.
All validation logic is applied at the entry point of the API before any processing or model inference occurs.
Required Headers
Every request must include the following headers to pass initial validation:
| Header | Value | Description |
| :--- | :--- | :--- |
| Content-Type | application/json | The API only accepts JSON payloads. |
| Authorization | Bearer <token> | A valid API key or JWT is required for all endpoints. |
Common Validation Constraints
The following constraints are globally applied across the testing suite:
- Model Identifiers: Must be non-empty strings and correspond to a registered model in the Supervised AI platform.
- Confidence Thresholds: Numerical values (floats) must be between
0.0and1.0. - Batch Size: For batch testing endpoints, the number of test cases must not exceed 500 per request.
- Payload Size: Total request body size is limited to 5MB.
Request Payload Structure
When submitting a test case, the API validates specific object types. Below is the standard validation schema for a test execution request.
Example: Validating a Text Classification Test
{
"model_id": "sentiment-analyzer-v1",
"test_suite": "production-sanity-check",
"parameters": {
"temperature": 0.7,
"max_tokens": 150
},
"inputs": [
{
"id": "req_001",
"text": "The model performance exceeded expectations."
}
]
}
Validation Error Format
If a request fails validation, the API returns a structured JSON response identifying the specific field and the reason for the failure.
Status Code: 400 Bad Request
{
"status": "error",
"type": "ValidationError",
"message": "Invalid input provided",
"details": [
{
"field": "parameters.temperature",
"issue": "Value must be less than or equal to 1.0",
"received": 1.5
},
{
"field": "inputs[0].text",
"issue": "Field is required",
"received": null
}
]
}
Internal Validation Logic
While the API uses schema-based validation internally to verify data types (Strings, Integers, Booleans) and structural integrity (Arrays, Nested Objects), users should primarily ensure their client-side logic respects the constraints defined in the specific endpoint's API contract.
Custom validation hooks may be triggered for specific AI domain tasks (e.g., verifying that a bounding box coordinate is within the image dimensions provided).