Validation
Validating incoming data is critical for security and stability. BustAPI includes a robust validation system based on strict types.
The Struct Class
Define your data schemas by subclassing Struct and using the special types provided by bustapi.safe.
Supported Types
StringIntegerFloatBooleanArray(Type): List of items
Example Schema
from bustapi.safe import Struct, String, Integer, Array
class Address(Struct):
street: String
city: String
zip: Integer
class User(Struct):
name: String
age: Integer
tags: Array(String)
address: Address # Nested Struct!
Using in Routes
Simply type-hint your route parameter. BustAPI handles parsing, validation, and error reporting (422 Unprocessable Entity) automatically.