<?php
function sendResponse($status, $message, $data = null) {
    http_response_code($status);
    $response = [
        "status" => $status,
        "message" => $message
    ];

    if ($data !== null) {
        $response["data"] = $data;
    }


    echo json_encode($response);
    exit;
}

function validateFeild($value, $fieldName) {
    if (!isset($value) || trim($value) === "") {
        sendResponse(400, "$fieldName is required");
    }
}
function validatePositiveNumber($value, $fieldName) {
    if (!is_numeric($value)) {
        sendResponse(400, "$fieldName must be a number");
    }

    if ($value <= 0) {
        sendResponse(400, "$fieldName must be greater than 0");
    }
}

?>