Add handling for forced prices, arrays, and improved type checks
Introduced support for forced pricing in `addItemToOrder` and added stricter validation for array inputs in SQL queries. Enhanced JSON handling in type validation and improved code reuse with new objects. Added new endpoint `/modules/xlvask/related-orders` to fetch related orders by wash IDs.
This commit is contained in:
@@ -34,6 +34,11 @@ trait route_t
|
||||
$value_type = gettype($value);
|
||||
// If the type is Array, or Object, json_decode the value to check if it is a valid JSON
|
||||
if ($type === 'array' || $type === 'object') {
|
||||
if (is_array($value)) {
|
||||
$value = json_encode($value);
|
||||
} elseif (is_object($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
$value = json_decode($value, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
global $response;
|
||||
@@ -44,7 +49,7 @@ trait route_t
|
||||
// Check if the value is of the required type
|
||||
if ($value_type !== $type) {
|
||||
global $response;
|
||||
$response->error('Invalid type. Expected: ' . $type . ' Got: ' . $value_type . ' Value: ' . $value, 400);
|
||||
$response->error('Invalid type. Expected: ' . $type . ' Got: ' . $value_type . ' Value: ' . (is_array($value) ? json_encode($value) : $value), 400);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user