bytes_schema
Returns a schema that matches a bytes value, e.g.:
from pydantic_core import SchemaValidator, core_schema
schema = core_schema.bytes_schema(max_length=10, min_length=2)
v = SchemaValidator(schema)
assert v.validate_python(b'hello') == b'hello'
def bytes_schema(
max_length: int | None = None,
min_length: int | None = None,
strict: bool | None = None,
ref: str | None = None,
metadata: dict[str, Any] | None = None,
serialization: SerSchema | None = None
) - > BytesSchema
Returns a schema that matches a bytes value.
Parameters
| Name | Type | Description |
|---|---|---|
| max_length | `int | None` = None |
| min_length | `int | None` = None |
| strict | `bool | None` = None |
| ref | `str | None` = None |
| metadata | `dict[str, Any] | None` = None |
| serialization | `SerSchema | None` = None |
Returns
| Type | Description |
|---|---|
BytesSchema | A dictionary-based schema definition for validating and serializing bytes data. |