Skip to content

$model->isValid() doesn't fire validating event #168

@adamthehutt

Description

@adamthehutt

Not sure if I'm doing something wrong or if this is a bug or intentional...

But when I call $model->save() on a model that uses the ValidatingTrait, the eloquent.validating event is fired before validation, which allows for some cleanup, setting of default properties, etc.

However, if I just call $model->isValid(), the eloquent.validating event does not seem to be triggered, so validation fails (when it would have succeeded in the context of saving).

Being able to call isValid() without saving would be particularly useful in tests, since there's no need to hit the database.

From looking at the code, it appears that both ValidatingTrait and ValidatingObserver have methods called performValidation(). The ValidatingObserver one invokes the events, while the trait one doesn't.

Any idea how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions