Closed
Description
I believe you should be able to enable more elaborate coercion of data types.
For example, coercing 'on' to true, or 'off' to false.
This could be implemented via a custom callback.
Just swap out functions like TypeConstrain->toBoolean() with optional custom callbacks.
For example:
$v = new \JsonSchema\Validator();
$v->setBooleanCoercion(function ($value)
{
if ($value === 'true' || $value === 'on') {
return true;
}
if ($value === 'false' || $value === 'off') {
return false;
}
return $value;
}
});
Metadata
Metadata
Assignees
Labels
No labels