openmediavault/openmediavault · error · SchemaValidationException
: The value is not a number.
Error message
%s: The value %s is not a number.
What it means
This is thrown by openmediavault's JSON schema validator (openmediavault\json\Schema::validateNumber) when a value bound to a schema node of type "number" fails is_numeric(). The library enforces JSON-Schema-style type constraints before applying numeric constraints like minimum/maximum. The exception message interpolates the schema property path ($name) and a JSON-encoded dump of the offending value.
Solutions
- Cast the value to the right type before validation: is_numeric($v) ? $v + 0 : $v (int or float).
- Fix the caller (form/RPC client) to emit real JSON numbers instead of quoted strings.
- If the field may legitimately be a string or number, change the schema to "type": ["number", "string"] or add a custom coercion.
- Inspect the $name prefix in the message to locate the exact property in the schema and the offending payload with json_encode_safe.
Example fix
// before $data = ['shares' => [['size' => $_POST['size']]]]; // '1024' (string) $object->validate($data, $schema); // after $data = ['shares' => [['size' => is_numeric($_POST['size']) ? $_POST['size'] + 0 : 0]]]; $object->validate($data, $schema);
Defensive patterns
Strategy: validation
Validate before calling
// PHP: ensure numeric before calling Schema->validate()
function assertNumber($v): void {
if (!is_numeric($v)) {
throw new InvalidArgumentException('Expected number, got: ' . json_encode_safe($v));
}
} Type guard
function isNumber($v): bool { return is_int($v) || is_float($v) || is_numeric($v); } Try / catch
try {
$object->validate($data, $schema);
} catch (OMV\Json\SchemaValidationException $e) {
$logger->error('Schema validation failed: ' . $e->getMessage());
// reject request / return 400
} Prevention
- Cast form/CLI inputs with +0 or (float) before building the config payload.
- Never quote numbers in JSON payloads emitted by clients.
- Validate one schema node in a unit test with both valid and invalid types.
- Prefer strict comparisons and gettype() checks when normalizing external input.
When it happens
Trigger: Calling Schema->validate($data, $schema) (directly or via rpc/config request validation) where a schema property declares "type": "number" but the supplied data is a string, bool, null, array or object, e.g. {"port": "8080"} instead of {"port": 8080}. Also occurs when numeric values are submitted as strings from HTML forms or CLI arguments without casting.
Common situations: Frontend form fields submitting numeric config values as strings; RPC clients sending quoted numbers in JSON; PHP code reading values from text config files or $_GET/$_POST (always strings) and passing them into the config schema; decoders that preserve "8080" as a string.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- : The value is not a string.
- : The value is not an array.
- : The value is not an object.
- : The value is not NULL.
- : The type ' ' is not defined.
AI-assisted analysis of openmediavault/openmediavault@dce610eb66 (2026-09-15).
Data as JSON: /api/errors/fbe11bb2a6ba5f7a.
Report an issue: GitHub.
Appendix: source
Thrown at deb/openmediavault/usr/share/php/openmediavault/json/schema.inc:401
throw new SchemaValidationException(
"%s: The value %s is not an integer.",
$name,
json_encode_safe($value)
);
}
$this->checkMinimum($value, $schema, $name);
$this->checkExclusiveMinimum($value, $schema, $name);
$this->checkMaximum($value, $schema, $name);
$this->checkExclusiveMaximum($value, $schema, $name);
$this->checkEnum($value, $schema, $name);
$this->checkOneOf($value, $schema, $name);
$this->checkNot($value, $schema, $name);
}
protected function validateNumber($value, $schema, $name)
{
if (!is_numeric($value)) {
throw new SchemaValidationException(
"%s: The value %s is not a number.",
$name,
json_encode_safe($value)
);
}
$this->checkMinimum($value, $schema, $name);
$this->checkExclusiveMinimum($value, $schema, $name);
$this->checkMaximum($value, $schema, $name);
$this->checkExclusiveMaximum($value, $schema, $name);
$this->checkEnum($value, $schema, $name);
$this->checkOneOf($value, $schema, $name);
$this->checkNot($value, $schema, $name);
}
protected function validateString($value, $schema, $name)
{
if (!is_string($value)) {
throw new SchemaValidationException(View on GitHub (pinned to dce610eb66)