From ef1a93b16c4428fe38596a33425a153aafa99bde Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 5 Dec 2024 17:33:27 +1300 Subject: [PATCH] API Rename validator classes --- code/BasicFieldsTestPage.php | 4 ++-- code/Company.php | 4 ++-- code/Employee.php | 4 ++-- code/GridFieldArbitraryData/ArbitraryDataModel.php | 2 +- code/elemental/ElementContentExtension.php | 6 +++--- code/multitab-validation/MultiTabPage.php | 6 +++--- code/multitab-validation/SingleTabPage.php | 4 ++-- code/recaptcha/RecaptchaTestPage.php | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 57af0e3..ef5a54b 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -31,7 +31,7 @@ use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\FieldGroup; use SilverStripe\Forms\CompositeField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\HTMLReadonlyField; class BasicFieldsTestPage extends TestPage @@ -399,7 +399,7 @@ public function getCMSFields() public function getCMSValidator() { - return new RequiredFields('Required'); + return new RequiredFieldsValidator('Required'); } public function validate() diff --git a/code/Company.php b/code/Company.php index 552f6b2..c75ee00 100644 --- a/code/Company.php +++ b/code/Company.php @@ -13,7 +13,7 @@ use SilverStripe\Versioned\Versioned; use RelationFieldsTestPage; use GridFieldTestPage; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; /** * @@ -103,7 +103,7 @@ public function getCMSFields() public function getCMSValidator() { - return new RequiredFields( + return new RequiredFieldsValidator( ['Name'] ); } diff --git a/code/Employee.php b/code/Employee.php index cb0ee06..2377d1c 100644 --- a/code/Employee.php +++ b/code/Employee.php @@ -5,7 +5,7 @@ use SilverStripe\Assets\Image; use SilverStripe\Forms\EmailField; use SilverStripe\Forms\NumericField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\TextField; use SilverStripe\ORM\Connect\MySQLSchemaManager; use SilverStripe\ORM\DataObject; @@ -144,7 +144,7 @@ public function requireDefaultRecords() public function getCMSValidator() { - return new RequiredFields( + return new RequiredFieldsValidator( ['Name'] ); } diff --git a/code/GridFieldArbitraryData/ArbitraryDataModel.php b/code/GridFieldArbitraryData/ArbitraryDataModel.php index 2bd3d3b..21c2350 100644 --- a/code/GridFieldArbitraryData/ArbitraryDataModel.php +++ b/code/GridFieldArbitraryData/ArbitraryDataModel.php @@ -176,7 +176,7 @@ public function getCMSFields(): FieldList // { // return CompositeValidator::create([ // FieldsValidator::create(), - // RequiredFields::create(['Title']), + // RequiredFieldsValidator::create(['Title']), // ]); // } diff --git a/code/elemental/ElementContentExtension.php b/code/elemental/ElementContentExtension.php index 7a162a6..a8116f1 100644 --- a/code/elemental/ElementContentExtension.php +++ b/code/elemental/ElementContentExtension.php @@ -7,9 +7,9 @@ use SilverStripe\Core\Extension; use SilverStripe\Forms\FieldList; use SilverStripe\Core\Validation\ValidationResult; -use SilverStripe\Forms\CompositeValidator; +use SilverStripe\Forms\Validation\CompositeValidator; use SilverStripe\Forms\NumericField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\SearchableDropdownField; use SilverStripe\Forms\TextField; @@ -43,7 +43,7 @@ protected function updateValidate(ValidationResult $result) protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator) { - $compositeValidator->addValidator(new RequiredFields(['Title', 'MyPageID', 'MyFile'])); + $compositeValidator->addValidator(new RequiredFieldsValidator(['Title', 'MyPageID', 'MyFile'])); } protected function updateCMSFields(FieldList $fields) diff --git a/code/multitab-validation/MultiTabPage.php b/code/multitab-validation/MultiTabPage.php index 048c480..a3572c2 100644 --- a/code/multitab-validation/MultiTabPage.php +++ b/code/multitab-validation/MultiTabPage.php @@ -4,7 +4,7 @@ use Page; use SilverStripe\Forms\EmailField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\TextField; if (!class_exists(Page::class)) { @@ -51,7 +51,7 @@ public function getSettingsFields() public function getCMSValidator() { - return new RequiredFields([ + return new RequiredFieldsValidator([ 'ThirdTabFirstField', 'FourthTabFirstField', // This is only validated if you are actually on the settings tab when clicking save @@ -63,7 +63,7 @@ public function validate() { $result = parent::validate(); - // Validation error on specific form field that is not in RequiredFields + // Validation error on specific form field that is not in RequiredFieldsValidator if ($this->SecondTabFirstField && $this->SecondTabFirstField !== '222') { $result->addFieldError('SecondTabFirstField', 'Value of field must be 222'); } diff --git a/code/multitab-validation/SingleTabPage.php b/code/multitab-validation/SingleTabPage.php index 8629e91..a1993e8 100644 --- a/code/multitab-validation/SingleTabPage.php +++ b/code/multitab-validation/SingleTabPage.php @@ -3,7 +3,7 @@ namespace SilverStripe\FrameworkTest\Model; use Page; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\Tab; if (!class_exists(Page::class)) { @@ -19,7 +19,7 @@ class SingleTabPage extends Page public function getCMSValidator() { - return new RequiredFields([ + return new RequiredFieldsValidator([ 'Content' ]); } diff --git a/code/recaptcha/RecaptchaTestPage.php b/code/recaptcha/RecaptchaTestPage.php index 379e450..8a40a8e 100644 --- a/code/recaptcha/RecaptchaTestPage.php +++ b/code/recaptcha/RecaptchaTestPage.php @@ -4,7 +4,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\FormAction; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\Form; use SilverStripe\Control\Director; use SilverStripe\Control\HTTPResponse; @@ -34,7 +34,7 @@ public function Form() new FieldList( new FormAction('submit', 'submit') ), - new RequiredFields(array('MyText')) + new RequiredFieldsValidator(array('MyText')) ); return $form;