call_schema
Returns a schema that matches an arguments schema, then calls a function, e.g.:
```py
from pydantic_core import SchemaValidator, core_schema
param_a = core_schema.arguments_parameter(
name='a', schema=core_schema.str_schema(), mode='positional_only'
)
param_b = core_schema.arguments_parameter(
name='b', schema=core_schema.bool_schema(), mode='positional_only'
)
args_schema = core_schema.arguments_schema([param_a, param_b])
schema = core_schema.call_schema(
arguments=args_schema,
function=lambda a, b: a + str(not b),
return_schema=core_schema.str_schema(),
)
v = SchemaValidator(schema)
assert v.validate_python((('hello', True))) == 'helloFalse'
```
def call_schema(
arguments: CoreSchema,
function: Callable[..., Any],
function_name: str | None = null,
return_schema: CoreSchema | None = null,
ref: str | None = null,
metadata: dict[str, Any] | None = null,
serialization: SerSchema | None = null
) - > CallSchema
Returns a schema that matches an arguments schema, then calls a function.
Parameters
| Name | Type | Description |
|---|---|---|
| arguments | CoreSchema | The schema used to validate and parse the input arguments before the function call. |
| function | Callable[..., Any] | The callable object to be executed using the validated arguments. |
| function_name | `str | None` = null |
| return_schema | `CoreSchema | None` = null |
| ref | `str | None` = null |
| metadata | `dict[str, Any] | None` = null |
| serialization | `SerSchema | None` = null |
Returns
| Type | Description |
|---|---|
CallSchema | A schema definition that validates input arguments and executes the specified callable with the validated data. |