validating
validating copied to clipboard
Bypass validation on delete
Is there is a way to bypass all validation on deletion, without having to specify separate rule sets? Something similar to forceSave()
?
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();
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).