validating icon indicating copy to clipboard operation
validating copied to clipboard

Bypass validation on delete

Open chriscook opened this issue 9 years ago • 2 comments

Is there is a way to bypass all validation on deletion, without having to specify separate rule sets? Something similar to forceSave()?

chriscook avatar Sep 10 '14 09:09 chriscook

I like this idea, I'll take a look into it. Unfortunately forceDelete() is already taken by soft deleting though.

You can still achieve this though, something like:

$user->setValidating(false);
$user->delete();

dwightwatson avatar Sep 11 '14 00:09 dwightwatson

Ah, I hadn't spotted setValidating(). Thanks- that will help me a lot.

One idea could be to have an array property on the model to determine which operations to validate on;

protected $validateOn = [
    'create',
    'update'
];

For models without the property, all operations would trigger validation (same as it currently is).

It could even be beneficial to be able to specify rule sets for each operation:

protected $validateOn = [
    'create' => 'saving',
    'update' => 'updating'
];

(if they're not specified, use the default rule set).

chriscook avatar Sep 11 '14 08:09 chriscook