Open samjurriaans opened 7 months ago
Two more alternatives to automatically validating + throwing an exception:
Entry::make()->save()
return false when the entry is invalid/cannot be savedEntry::make()->validate()->save()
that we can call manually to validate content before saving - this could throw an exceptionOr just have all of the above :)
Today I ran into a situation that the Statamic Control Panel was not working, due to a NavItem object not being able to successfully call the function resolveChildren(). The exact error was as follows:
The bug itself was in a way totally unrelated to the navigation, since it was caused by the following seeder of mine:
Some of you may now already see what the cause of the problem is: The saved role was missing a filled in title property and the fix was as follows:
It took me quite some time to figure out what the problem was. And I was thinking that it would have been very helpful to have either a more helpfull error in the control panel or that I would have wanted to see the error already during the saving of the role.
To me it seems like the best approach the have some kind of validation in place that throws an error the moment I try to save any Statamic Objects programmatically that is application breaking.
So my feature request would be to add error throwing validation when one tries to save Statamic objects like Entries and Roles e.g.