Skip to content
docsv0.2.0

SchemaValidator

JSON Schema validator for tool arguments. Validates arguments against the tool's input schema before execution.

SchemaValidator::validate()

public function validate(array $args, array $schema): Milpa\ToolRuntime\Validation\ValidationResult

Validate arguments against a JSON schema.

Parameters

Parameters of validate()
NameTypeDescription
$argsarray<string, mixed>The arguments to validate
$schemaarray<string, mixed>The JSON schema

SchemaValidator::applyClamps()

public function applyClamps(array $args, array $clamps): array

Validate and apply clamps to arguments.

Parameters

Parameters of applyClamps()
NameTypeDescription
$argsarray<string, mixed>Arguments to clamp
$clampsarray<string, array<string, mixed>>Clamp definitions ['field' => ['min' => x, 'max' => y]]

Returns

Clamped arguments