phalcon/cphalcon · error · Phalcon\Mvc\Model\ValidationFailed

{validationMessage}

Error message

{validationMessage}

What it means

save() failed pre-save validation (a model validator produced messages), and with orm.exception_on_failed_save enabled Phalcon throws a ValidationFailed carrying the first validation message instead of returning false.

Solutions

  1. Inspect getMessages() on the model (or the exception) to see which validation rule failed
  2. Fix the offending field values or relax the validator; disable exception_on_failed_save to handle failures via return values
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at phalcon/Mvc/Model.zep:2945 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/3d228e0bc3694222. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model.zep:2945

        if this->preSave(metaData, exists, identityField) === false {
            /**
             * Rollback the current transaction if there was validation errors
             */
            if hasRelatedToSave {
                writeConnection->rollback(false);
            }

            let this->syncRelated = [];

            /**
             * Throw exceptions on failed saves?
             */
            if unlikely Settings::get("orm.exception_on_failed_save") {
                /**
                 * Launch a Phalcon\Mvc\Model\ValidationFailed to notify that
                 * the save failed
                 */
                throw new ValidationFailed(
                    this,
                    this->getMessages()
                );
            }

            return false;
        }

        /**
         * Capture the current snapshot before the write so it can be restored
         * if postSaveRelatedRecords later rolls back the transaction
         */
        let manager = this->getModelsManager();

        if manager->isKeepingSnapshots(this) && Settings::get("orm.update_snapshot_on_save") {
            let savedSnapshot    = this->snapshot,
                savedOldSnapshot = this->oldSnapshot;
        }

View on GitHub (pinned to b7419de9cd)