Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Rename validator classes #214

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/BasicFieldsTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -399,7 +399,7 @@ public function getCMSFields()

public function getCMSValidator()
{
return new RequiredFields('Required');
return new RequiredFieldsValidator('Required');
}

public function validate()
Expand Down
4 changes: 2 additions & 2 deletions code/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use SilverStripe\Versioned\Versioned;
use RelationFieldsTestPage;
use GridFieldTestPage;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;

/**
*
Expand Down Expand Up @@ -103,7 +103,7 @@ public function getCMSFields()

public function getCMSValidator()
{
return new RequiredFields(
return new RequiredFieldsValidator(
['Name']
);
}
Expand Down
4 changes: 2 additions & 2 deletions code/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,7 +144,7 @@ public function requireDefaultRecords()

public function getCMSValidator()
{
return new RequiredFields(
return new RequiredFieldsValidator(
['Name']
);
}
Expand Down
2 changes: 1 addition & 1 deletion code/GridFieldArbitraryData/ArbitraryDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function getCMSFields(): FieldList
// {
// return CompositeValidator::create([
// FieldsValidator::create(),
// RequiredFields::create(['Title']),
// RequiredFieldsValidator::create(['Title']),
// ]);
// }

Expand Down
6 changes: 3 additions & 3 deletions code/elemental/ElementContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions code/multitab-validation/MultiTabPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand All @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions code/multitab-validation/SingleTabPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -19,7 +19,7 @@ class SingleTabPage extends Page

public function getCMSValidator()
{
return new RequiredFields([
return new RequiredFieldsValidator([
'Content'
]);
}
Expand Down
4 changes: 2 additions & 2 deletions code/recaptcha/RecaptchaTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,7 +34,7 @@ public function Form()
new FieldList(
new FormAction('submit', 'submit')
),
new RequiredFields(array('MyText'))
new RequiredFieldsValidator(array('MyText'))
);

return $form;
Expand Down
Loading