{"record":{"id":"2af235cf3884c480","repo":"phalcon/cphalcon","slug":"there-is-no-data-to-validate","errorCode":null,"errorMessage":"There is no data to validate","messagePattern":"There is no data to validate","errorType":"exception","errorClass":"Phalcon\\Filter\\Validation\\Exceptions\\NoDataToValidate","httpStatus":null,"severity":"error","filePath":"phalcon/Filter/Validation.zep","lineNumber":432,"sourceCode":"    {\n        var entity, method, value, data, filters, fieldFilters,\n            container, filterService;\n        bool isRawFetched;\n\n        let isRawFetched = false;\n        let entity = this->entity;\n        let data = this->data;\n\n        //  If the entity is an object use it to retrieve the values\n        if typeof entity == \"object\" {\n            let value = this->getValueByEntity(entity, field);\n            if value === null {\n                let isRawFetched = true;\n                let value = this->getValueByData(data, field);\n            }\n        } else {\n            if unlikely (typeof data != \"array\" && typeof data != \"object\") {\n                throw new NoDataToValidate();\n            }\n            let value = this->getValueByData(data, field);\n        }\n\n        if value === null {\n            return null;\n        }\n\n        let filters = this->filters;\n\n        if fetch fieldFilters, filters[field] {\n            if fieldFilters {\n                let container = this->getDI();\n\n                if container === null {\n                    let container = Di::getDefault();\n\n                    if container === null {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Filter/Validation.zep#L414-L450","documentation":"Validation::getValue(field) reads the current value either from the bound entity or from the bound data. When no entity object is set, it falls back to $this->data and requires that data be an array or object; NoDataToValidate is thrown when it is neither (null, string, int...), meaning there is nothing to read the field from.","triggerScenarios":"Calling $validation->getValue('email') before any bind()/validate() set data (property defaults to null); bind($entity, null) with a non-object entity; passing a raw JSON string as data: $v->validate($request->getRawBody()) then getValue() in a validator.","commonSituations":"Validators that call getValue() during rendering messages when the validation was constructed but never bound; forgetting json_decode() on a request body; data variable lost through an early return before bind().","solutions":["Bind array data first: $validation->bind($entity, $dataArray) or call validate($dataArray)","json_decode() string payloads into arrays before validating: $data = json_decode($raw, true)","Ensure getValue() is only called after a successful bind/validate path has populated data or entity"],"exampleFix":"// before\n$v = new Validation();\n$v->add('email', new Email());\n$value = $v->getValue('email'); // throws NoDataToValidate: data is null\n\n// after\n$v = new Validation();\n$v->add('email', new Email());\n$value = $v->getValue('email'); // after $v->validate($_POST) or $v->bind(null, $_POST)","handlingStrategy":"validation","validationCode":"$data = $validation->getData();\nif ($validation->getEntity() === null && !is_array($data) && !is_object($data)) {\n    throw new RuntimeException('No data bound: call bind() or validate($arrayData) before getValue()');\n}\nreturn $validation->getValue($field);","typeGuard":"function hasBoundData(\\Phalcon\\Filter\\Validation $v): bool\n{\n    return is_object($v->getEntity()) || is_array($v->getData()) || is_object($v->getData());\n}","tryCatchPattern":"use Phalcon\\Filter\\Validation\\Exceptions\\NoDataToValidate;\ntry {\n    $value = $v->getValue('email');\n} catch (NoDataToValidate $e) {\n    $value = null; // no payload submitted yet (e.g. first render of an empty form)\n}","preventionTips":["Decode JSON bodies to arrays before validate()/bind()","Only call getValue() after bind()/validate() has populated entity or data","Treat 'data === null' as 'form not submitted' and short-circuit before validation"],"tags":["phalcon","validation","missing-data","bind"],"backgroundTag":"missing-validation-data","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}