From 955ea8115343695955bc55a4ff3d4bc6b6c01e3a Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 7 Feb 2025 12:28:04 +1300 Subject: [PATCH] DOC Show more information in ValidationException message --- en/02_Developer_Guides/00_Model/09_Validation.md | 3 +++ en/08_Changelogs/6.0.0.md | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/en/02_Developer_Guides/00_Model/09_Validation.md b/en/02_Developer_Guides/00_Model/09_Validation.md index 57ce8d52..19327651 100644 --- a/en/02_Developer_Guides/00_Model/09_Validation.md +++ b/en/02_Developer_Guides/00_Model/09_Validation.md @@ -44,6 +44,9 @@ sub-classes to specify custom validation, or use the `updateValidate()` extensio Invalid objects won't be able to be written - a [`ValidationException`](api:SilverStripe\Core\Validation\ValidationException) will be thrown and no write will occur. +If appropriate, you can call [`ValidationResult::setModelClass()`](api:SilverStripe\Core\Validation\ValidationResult::setModelClass()) +and [`ValidationResult::setRecordID()`](api:SilverStripe\Core\Validation\ValidationResult::setRecordID()) on your `ValidationResult` instance to set the class and ID of the object being validated. This additional info will show in the validation error messages in a CLI context, as well as in a non-CLI context if the current controller is an instance or a subclass of a controller configured in the [`ValidationException.show_additional_info_non_cli_controllers`](api:SilverStripe\Core\Validation\ValidationException->show_additional_info_non_cli_controllers) configuration. + The return value of `validate()` is a [`ValidationResult`](api:SilverStripe\Core\Validation\ValidationResult) object. ```php diff --git a/en/08_Changelogs/6.0.0.md b/en/08_Changelogs/6.0.0.md index 966d70e9..994902db 100644 --- a/en/08_Changelogs/6.0.0.md +++ b/en/08_Changelogs/6.0.0.md @@ -50,6 +50,7 @@ title: 6.0.0 (unreleased) - [Update JS MIME type, remove `type` in `