From a390e2d1015853ca3aac537423125e902df1b465 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 18 Dec 2024 12:25:53 +1300 Subject: [PATCH] DOC Update validate signature --- en/02_Developer_Guides/00_Model/09_Validation.md | 3 ++- en/08_Changelogs/6.0.0.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/en/02_Developer_Guides/00_Model/09_Validation.md b/en/02_Developer_Guides/00_Model/09_Validation.md index 12730e04..57ce8d52 100644 --- a/en/02_Developer_Guides/00_Model/09_Validation.md +++ b/en/02_Developer_Guides/00_Model/09_Validation.md @@ -49,6 +49,7 @@ The return value of `validate()` is a [`ValidationResult`](api:SilverStripe\Core ```php namespace App\Model; +use SilverStripe\Core\Validation\ValidationResult; use SilverStripe\ORM\DataObject; class MyObject extends DataObject @@ -58,7 +59,7 @@ class MyObject extends DataObject 'Postcode' => 'Varchar', ]; - public function validate() + public function validate(): ValidationResult { $result = parent::validate(); diff --git a/en/08_Changelogs/6.0.0.md b/en/08_Changelogs/6.0.0.md index 03f46aae..ef15b56d 100644 --- a/en/08_Changelogs/6.0.0.md +++ b/en/08_Changelogs/6.0.0.md @@ -31,6 +31,7 @@ title: 6.0.0 (unreleased) - [Bug fixes](#bug-fixes) - [API changes](#api-changes) - [Many renamed classes](#renamed-classes) + - [DataObject `validate()` signature change](#dataobject-validate) - [GraphQL removed from the CMS](#graphql-removed) - [`FormField` classes now use `FieldValidator` for validation](#formfield-validation) - [Most extension hook methods are now protected](#hooks-protected) @@ -1042,6 +1043,7 @@ As part of these changes [`ArrayList::find()`](api:SilverStripe\Model\List\Array ### General changes {#api-general} +- [`DataObject::validate()`](api:SilverStripe\ORM\DataObject::validate()) now has an explicit `ValidationResult` return type. - [`DataObject::write()`](api:SilverStripe\ORM\DataObject::write()) has a new boolean `$skipValidation` parameter. This can be useful for scenarios where you want to automatically create a new record with no data initially without restricting how developers can set up their validation rules. - [`FieldList`](api:SilverStripe\Forms\FieldList) is now strongly typed. Methods that previously allowed any iterable variables to be passed, namely [`FieldList::addFieldsToTab()`](api:SilverStripe\Forms\FieldList::addFieldsToTab()) and [`FieldList::removeFieldsFromTab()`](api:SilverStripe\Forms\FieldList::removeFieldsFromTab()), now require an array to be passed instead. - `DNADesign\Elemental\Models\BaseElement::getDescription()` and the corresponding `DNADesign\Elemental\Models\BaseElement.description` configuration property have been removed. If you were using either of these in your custom elemental blocks, either set the new [`class_description`](api:SilverStripe\ORM\DataObject->class_description) configuration property or override one of the [`i18n_classDescription()`](api:SilverStripe\ORM\DataObject::i18n_classDescription()) or [`getTypeNice()`](api:DNADesign\Elemental\Models\BaseElement::getTypeNice()) methods instead.