diff --git a/src/Forms/CompositeValidator.php b/src/Forms/CompositeValidator.php index cc4c508c1a7..e18190676e8 100644 --- a/src/Forms/CompositeValidator.php +++ b/src/Forms/CompositeValidator.php @@ -19,7 +19,7 @@ * { * $compositeValidator = parent::getCMSCompositeValidator(); * - * $compositeValidator->addValidator(RequiredFields::create(['MyRequiredField'])); + * $compositeValidator->addValidator(RequiredFieldsValidator::create(['MyRequiredField'])); * * return $compositeValidator * } @@ -28,7 +28,7 @@ * * protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void * { - * $compositeValidator->addValidator(RequiredFields::create(['AdditionalContent'])); + * $compositeValidator->addValidator(RequiredFieldsValidator::create(['AdditionalContent'])); * } */ class CompositeValidator extends Validator @@ -100,7 +100,7 @@ public function validate() } /** - * Note: The existing implementations for the php() method (@see RequiredFields) does not check whether the + * Note: The existing implementations for the php() method (@see RequiredFieldsValidator) does not check whether the * Validator is enabled or not, and it also does not reset the validation result - so, neither does this. * * @param array $data @@ -150,7 +150,7 @@ public function getValidators(): array } /** - * Return all Validators that match a certain class name. EG: RequiredFields::class + * Return all Validators that match a certain class name. EG: RequiredFieldsValidator::class * * The keys for the return array match the keys in the unfiltered array. You cannot assume the keys will be * sequential or that the first key will be ZERO. @@ -175,7 +175,7 @@ public function getValidatorsByType(string $className): array } /** - * Remove all Validators that match a certain class name. EG: RequiredFields::class + * Remove all Validators that match a certain class name. EG: RequiredFieldsValidator::class * * @param string $className * @return CompositeValidator diff --git a/src/Forms/FileField.php b/src/Forms/FileField.php index a4db0fba7c3..fdeed0a59d7 100644 --- a/src/Forms/FileField.php +++ b/src/Forms/FileField.php @@ -33,7 +33,7 @@ * $actions = new FieldList( * new FormAction('doUpload', 'Upload file') * ); - * $validator = new RequiredFields(['MyName', 'MyFile']); + * $validator = new RequiredFieldsValidator(['MyName', 'MyFile']); * * return new Form($this, 'Form', $fields, $actions, $validator); * } diff --git a/src/Forms/Form.php b/src/Forms/Form.php index a0483b68cc6..58a1a2f1796 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -44,7 +44,7 @@ * Each form needs some form of {@link Validator} to trigger the {@link FormField->validate()} methods for each field. * You can't disable validator for security reasons, because crucial behaviour like extension checks for file uploads * depend on it. - * The default validator is an instance of {@link RequiredFields}. + * The default validator is an instance of {@link RequiredFieldsValidator}. * If you want to enforce serverside-validation to be ignored for a specific {@link FormField}, * you need to subclass it. * @@ -274,7 +274,7 @@ class Form extends ModelData implements HasRequestHandler * @param FieldList $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects. * @param FieldList $actions All of the action buttons in the form - a {@link FieldLis} of * {@link FormAction} objects - * @param Validator|null $validator Override the default validator instance (Default: {@link RequiredFields}) + * @param Validator|null $validator Override the default validator instance (Default: {@link RequiredFieldsValidator}) */ public function __construct( RequestHandler $controller = null, @@ -297,7 +297,7 @@ public function __construct( $this->setName($name); // Form validation - $this->validator = ($validator) ? $validator : new RequiredFields(); + $this->validator = ($validator) ? $validator : new RequiredFieldsValidator(); $this->validator->setForm($this); // Form error controls diff --git a/src/Forms/FieldsValidator.php b/src/Forms/FormFieldsValidator.php similarity index 90% rename from src/Forms/FieldsValidator.php rename to src/Forms/FormFieldsValidator.php index 504cf6157f8..b3db2019a18 100644 --- a/src/Forms/FieldsValidator.php +++ b/src/Forms/FormFieldsValidator.php @@ -5,7 +5,7 @@ /** * Validates the internal state of all fields in the form. */ -class FieldsValidator extends Validator +class FormFieldsValidator extends Validator { public function php($data): bool { diff --git a/src/Forms/GridField/GridFieldDetailForm.php b/src/Forms/GridField/GridFieldDetailForm.php index 544f6221f3c..ae571c46747 100644 --- a/src/Forms/GridField/GridFieldDetailForm.php +++ b/src/Forms/GridField/GridFieldDetailForm.php @@ -14,7 +14,7 @@ use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injector; use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\FieldsValidator; +use SilverStripe\Forms\FormFieldsValidator; use SilverStripe\Forms\Validator; use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObject; @@ -148,7 +148,7 @@ public function handleItem($gridField, $request) if ($record->hasMethod('getCMSCompositeValidator')) { $validator = $record->getCMSCompositeValidator(); } else { - $validator = FieldsValidator::create(); + $validator = FormFieldsValidator::create(); } $this->setValidator($validator); } diff --git a/src/Forms/HasOneRelationFieldInterface.php b/src/Forms/HasOneRelationFieldInterface.php index b520cc9592a..e02451faf7c 100644 --- a/src/Forms/HasOneRelationFieldInterface.php +++ b/src/Forms/HasOneRelationFieldInterface.php @@ -4,7 +4,7 @@ /** * Added to form fields whose values are the ID of a has_one relation - * This is used in RequiredFields validation to check if the value is set + * This is used in RequiredFieldsValidator validation to check if the value is set */ interface HasOneRelationFieldInterface { diff --git a/src/Forms/RequiredFields.php b/src/Forms/RequiredFields.php index 6e2068aba82..d942bd6d0cf 100644 --- a/src/Forms/RequiredFields.php +++ b/src/Forms/RequiredFields.php @@ -12,7 +12,7 @@ * Validation is performed on a field by field basis through * {@link FormField::validate}. */ -class RequiredFields extends Validator +class RequiredFieldsValidator extends Validator { /** @@ -193,7 +193,7 @@ public function removeRequiredField($field) /** * Add {@link RequiredField} objects together * - * @param RequiredFields $requiredFields + * @param RequiredFieldsValidator $requiredFields * @return $this */ public function appendRequiredFields($requiredFields) diff --git a/src/Forms/Validator.php b/src/Forms/Validator.php index 786931ea87c..4a068a8272a 100644 --- a/src/Forms/Validator.php +++ b/src/Forms/Validator.php @@ -171,7 +171,7 @@ public function removeValidation() /** * When Validators are set on the form, it can affect whether or not the form cannot be cached. * - * @see RequiredFields for an example of when you might be able to cache your form. + * @see RequiredFieldsValidator for an example of when you might be able to cache your form. * * @return bool */ diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 586db64a941..a0b30db60d0 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -19,7 +19,7 @@ use SilverStripe\Forms\FormField; use SilverStripe\Forms\FormScaffolder; use SilverStripe\Forms\CompositeValidator; -use SilverStripe\Forms\FieldsValidator; +use SilverStripe\Forms\FormFieldsValidator; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; use SilverStripe\Forms\HiddenField; @@ -2686,7 +2686,7 @@ public function getCMSActions() */ public function getCMSCompositeValidator(): CompositeValidator { - $compositeValidator = CompositeValidator::create([FieldsValidator::create()]); + $compositeValidator = CompositeValidator::create([FormFieldsValidator::create()]); // Support for the old method during the deprecation period if ($this->hasMethod('getCMSValidator')) { diff --git a/src/Security/Group.php b/src/Security/Group.php index 6c10d32c073..47461b45232 100755 --- a/src/Security/Group.php +++ b/src/Security/Group.php @@ -23,7 +23,7 @@ use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig; use SilverStripe\Forms\ListboxField; use SilverStripe\Forms\LiteralField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\Tab; use SilverStripe\Forms\TabSet; use SilverStripe\Forms\TextareaField; @@ -559,7 +559,7 @@ public function getCMSCompositeValidator(): CompositeValidator { $validator = parent::getCMSCompositeValidator(); - $validator->addValidator(RequiredFields::create([ + $validator->addValidator(RequiredFieldsValidator::create([ 'Title' ])); diff --git a/src/Security/Member.php b/src/Security/Member.php index 4f139a9b8d0..06667176604 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -682,7 +682,7 @@ public function getMemberPasswordField() /** - * Returns the {@link RequiredFields} instance for the Member object. This + * Returns the {@link RequiredFieldsValidator} instance for the Member object. This * Validator is used when saving a {@link CMSProfileController} or added to * any form responsible for saving a users data. * diff --git a/src/Security/MemberAuthenticator/MemberLoginForm.php b/src/Security/MemberAuthenticator/MemberLoginForm.php index c88df53dc87..b4bb4ece77f 100644 --- a/src/Security/MemberAuthenticator/MemberLoginForm.php +++ b/src/Security/MemberAuthenticator/MemberLoginForm.php @@ -10,7 +10,7 @@ use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\PasswordField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\TextField; use SilverStripe\Core\Validation\ValidationResult; use SilverStripe\Security\LoginForm as BaseLoginForm; @@ -111,7 +111,7 @@ public function __construct( if (isset($logoutAction)) { $this->setFormAction($logoutAction); } - $this->setValidator(RequiredFields::create(static::config()->get('required_fields'))); + $this->setValidator(RequiredFieldsValidator::create(static::config()->get('required_fields'))); } /** diff --git a/src/Security/Member_Validator.php b/src/Security/Member_Validator.php index 6b979847dd7..a19bf76f30e 100644 --- a/src/Security/Member_Validator.php +++ b/src/Security/Member_Validator.php @@ -3,7 +3,7 @@ namespace SilverStripe\Security; use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; /** * Member Validator @@ -22,7 +22,7 @@ * - Surname * */ -class Member_Validator extends RequiredFields +class Member_Validator extends RequiredFieldsValidator { /** * Fields that are required by this validator diff --git a/tests/php/Forms/CheckboxFieldTest.php b/tests/php/Forms/CheckboxFieldTest.php index bbd3603492b..c1765af266d 100644 --- a/tests/php/Forms/CheckboxFieldTest.php +++ b/tests/php/Forms/CheckboxFieldTest.php @@ -9,7 +9,7 @@ use SilverStripe\ORM\DB; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\CheckboxField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; class CheckboxFieldTest extends SapphireTest { @@ -200,7 +200,7 @@ public function testNoAriaRequired() "form", new FieldList($field), new FieldList(), - new RequiredFields(["RequiredField"]) + new RequiredFieldsValidator(["RequiredField"]) ); $this->assertTrue($field->Required()); diff --git a/tests/php/Forms/CheckboxSetFieldTest.php b/tests/php/Forms/CheckboxSetFieldTest.php index a9c717ae753..751ed2145a6 100644 --- a/tests/php/Forms/CheckboxSetFieldTest.php +++ b/tests/php/Forms/CheckboxSetFieldTest.php @@ -15,7 +15,7 @@ use SilverStripe\Forms\CheckboxSetField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Model\ArrayData; class CheckboxSetFieldTest extends SapphireTest @@ -355,7 +355,7 @@ public function testNoAriaRequired() "form", new FieldList($field), new FieldList(), - new RequiredFields(["RequiredField"]) + new RequiredFieldsValidator(["RequiredField"]) ); $this->assertTrue($field->Required()); diff --git a/tests/php/Forms/CompositeFieldTest.php b/tests/php/Forms/CompositeFieldTest.php index f3b22dc711a..19845c8cd58 100644 --- a/tests/php/Forms/CompositeFieldTest.php +++ b/tests/php/Forms/CompositeFieldTest.php @@ -7,7 +7,7 @@ use SilverStripe\Forms\CompositeField; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\TextField; class CompositeFieldTest extends SapphireTest diff --git a/tests/php/Forms/CompositeValidatorTest.php b/tests/php/Forms/CompositeValidatorTest.php index bcd79a41caf..8f1e7ed4f15 100644 --- a/tests/php/Forms/CompositeValidatorTest.php +++ b/tests/php/Forms/CompositeValidatorTest.php @@ -8,7 +8,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\Tests\ValidatorTest\TestValidator; use SilverStripe\Forms\TextField; use SilverStripe\Forms\CompositeValidator; @@ -40,8 +40,8 @@ protected function getForm(array $fieldNames = []): Form public function testAddValidator(): void { $compositeValidator = new CompositeValidator(); - $compositeValidator->addValidator(new RequiredFields()); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $this->assertCount(2, $compositeValidator->getValidators()); } @@ -76,38 +76,38 @@ public function testSetForm(): void public function testGetValidatorsByType(): void { $compositeValidator = new CompositeValidator(); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $compositeValidator->addValidator(new TestValidator()); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $compositeValidator->addValidator(new TestValidator()); $this->assertCount(4, $compositeValidator->getValidators()); - $this->assertCount(2, $compositeValidator->getValidatorsByType(RequiredFields::class)); + $this->assertCount(2, $compositeValidator->getValidatorsByType(RequiredFieldsValidator::class)); } public function testRemoveValidatorsByType(): void { $compositeValidator = new CompositeValidator(); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $compositeValidator->addValidator(new TestValidator()); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $compositeValidator->addValidator(new TestValidator()); $this->assertCount(4, $compositeValidator->getValidators()); - $compositeValidator->removeValidatorsByType(RequiredFields::class); + $compositeValidator->removeValidatorsByType(RequiredFieldsValidator::class); $this->assertCount(2, $compositeValidator->getValidators()); } public function testCanBeCached(): void { $compositeValidator = new CompositeValidator(); - $compositeValidator->addValidator(new RequiredFields()); + $compositeValidator->addValidator(new RequiredFieldsValidator()); $this->assertTrue($compositeValidator->canBeCached()); $compositeValidator = new CompositeValidator(); - $compositeValidator->addValidator(new RequiredFields(['Foor'])); + $compositeValidator->addValidator(new RequiredFieldsValidator(['Foor'])); $this->assertFalse($compositeValidator->canBeCached()); } @@ -121,12 +121,12 @@ public function testFieldIsRequired(): void 'Content', ]; - $requiredFieldsFirst = new RequiredFields( + $requiredFieldsFirst = new RequiredFieldsValidator( [ $fieldNames[0], ] ); - $requiredFieldsSecond = new RequiredFields( + $requiredFieldsSecond = new RequiredFieldsValidator( [ $fieldNames[1], ] @@ -147,8 +147,8 @@ public function testValidate(): void { $compositeValidator = new CompositeValidator(); // Add two separate validators, each with one required field - $compositeValidator->addValidator(new RequiredFields(['Foo'])); - $compositeValidator->addValidator(new RequiredFields(['Bar'])); + $compositeValidator->addValidator(new RequiredFieldsValidator(['Foo'])); + $compositeValidator->addValidator(new RequiredFieldsValidator(['Bar'])); // Setup a form with the fields/data we're testing (a form is a dependency for validation right now) // We'll add three empty fields, but only two of them should be required diff --git a/tests/php/Forms/ConfirmedPasswordFieldTest.php b/tests/php/Forms/ConfirmedPasswordFieldTest.php index 7fb6f643d3f..c34b6c16067 100644 --- a/tests/php/Forms/ConfirmedPasswordFieldTest.php +++ b/tests/php/Forms/ConfirmedPasswordFieldTest.php @@ -9,7 +9,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\ReadonlyField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Security\Member; use SilverStripe\View\SSViewer; use Closure; @@ -466,7 +466,7 @@ public function testChildFieldsAreRequired(bool $canBeEmpty, bool $required, boo $requiredFields[] = 'Test[_Password]'; $requiredFields[] = 'Test[_ConfirmPassword]'; } - $form->setValidator(new RequiredFields($requiredFields)); + $form->setValidator(new RequiredFieldsValidator($requiredFields)); $rendered = $field->Field(); $fieldOneRegex = ']*?required="required"\s+aria-required="true"\s[^>]*\/>'; diff --git a/tests/php/Forms/CurrencyFieldTest.php b/tests/php/Forms/CurrencyFieldTest.php index af08d227595..ae7b28f98c4 100644 --- a/tests/php/Forms/CurrencyFieldTest.php +++ b/tests/php/Forms/CurrencyFieldTest.php @@ -6,7 +6,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\CurrencyField; use SilverStripe\Forms\CurrencyField_Readonly; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\ORM\FieldType\DBCurrency; class CurrencyFieldTest extends SapphireTest diff --git a/tests/php/Forms/DateFieldTest.php b/tests/php/Forms/DateFieldTest.php index 9ac536bc2e3..042c1c8d2a2 100644 --- a/tests/php/Forms/DateFieldTest.php +++ b/tests/php/Forms/DateFieldTest.php @@ -7,7 +7,7 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\DateField; use SilverStripe\Forms\DateField_Disabled; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\i18n\i18n; use SilverStripe\ORM\FieldType\DBDate; use SilverStripe\ORM\FieldType\DBDatetime; diff --git a/tests/php/Forms/DatetimeFieldTest.php b/tests/php/Forms/DatetimeFieldTest.php index 68e31a4eac8..8c30013343a 100644 --- a/tests/php/Forms/DatetimeFieldTest.php +++ b/tests/php/Forms/DatetimeFieldTest.php @@ -9,7 +9,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\Tests\DatetimeFieldTest\Model; use SilverStripe\i18n\i18n; use SilverStripe\ORM\FieldType\DBDatetime; diff --git a/tests/php/Forms/DropdownFieldTest.php b/tests/php/Forms/DropdownFieldTest.php index 8e4de0e2fbe..0213c0950e1 100644 --- a/tests/php/Forms/DropdownFieldTest.php +++ b/tests/php/Forms/DropdownFieldTest.php @@ -7,7 +7,7 @@ use SilverStripe\Dev\CSSContentParser; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\DropdownField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\FormTemplateHelper; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; @@ -574,7 +574,7 @@ public function testRequiredDropdownHasEmptyDefault() "form", new FieldList($field), new FieldList(), - new RequiredFields(["RequiredField"]) + new RequiredFieldsValidator(["RequiredField"]) ); $this->assertTrue($field->getHasEmptyDefault()); diff --git a/tests/php/Forms/EmailFieldTest.php b/tests/php/Forms/EmailFieldTest.php index d46ceae1214..106aca3ca37 100644 --- a/tests/php/Forms/EmailFieldTest.php +++ b/tests/php/Forms/EmailFieldTest.php @@ -4,7 +4,7 @@ use SilverStripe\Dev\FunctionalTest; use SilverStripe\Forms\EmailField; -use SilverStripe\Forms\FieldsValidator; +use SilverStripe\Forms\FormFieldsValidator; class EmailFieldTest extends FunctionalTest { diff --git a/tests/php/Forms/EmailFieldTest/TestController.php b/tests/php/Forms/EmailFieldTest/TestController.php index fd01418e34f..3e5546e0322 100644 --- a/tests/php/Forms/EmailFieldTest/TestController.php +++ b/tests/php/Forms/EmailFieldTest/TestController.php @@ -9,7 +9,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\View\SSViewer; class TestController extends Controller implements TestOnly @@ -54,7 +54,7 @@ public function Form() new FieldList( new FormAction('doSubmit') ), - new RequiredFields( + new RequiredFieldsValidator( 'Email' ) ); diff --git a/tests/php/Forms/FieldsValidatorTest.php b/tests/php/Forms/FieldsValidatorTest.php index d5eac24d9c4..88d328fab21 100644 --- a/tests/php/Forms/FieldsValidatorTest.php +++ b/tests/php/Forms/FieldsValidatorTest.php @@ -5,11 +5,11 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\EmailField; use SilverStripe\Forms\FieldList; -use SilverStripe\Forms\FieldsValidator; +use SilverStripe\Forms\FormFieldsValidator; use SilverStripe\Forms\Form; use PHPUnit\Framework\Attributes\DataProvider; -class FieldsValidatorTest extends SapphireTest +class FormFieldsValidatorTest extends SapphireTest { protected $usesDatabase = false; @@ -64,7 +64,7 @@ public function testValidation(array $values, bool $isValid) if (array_key_exists('EmailField2', $values)) { $field2->setValue($values['EmailField2']); } - $form = new Form(null, 'testForm', $fieldList, new FieldList([/* no actions */]), new FieldsValidator()); + $form = new Form(null, 'testForm', $fieldList, new FieldList([/* no actions */]), new FormFieldsValidator()); $result = $form->validationResult(); $this->assertSame($isValid, $result->isValid()); diff --git a/tests/php/Forms/FileFieldTest.php b/tests/php/Forms/FileFieldTest.php index 3529b5eea1f..45411ebe5a9 100644 --- a/tests/php/Forms/FileFieldTest.php +++ b/tests/php/Forms/FileFieldTest.php @@ -10,7 +10,7 @@ use SilverStripe\Forms\FileField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; class FileFieldTest extends FunctionalTest { @@ -126,7 +126,7 @@ public function testUploadMissingRequiredFile() $fileField = new FileField('cv', 'Upload your CV') ), new FieldList(), - new RequiredFields('cv') + new RequiredFieldsValidator('cv') ); // All fields are filled but for some reason an error occurred when uploading the file => fails $fileFieldValue = [ diff --git a/tests/php/Forms/FormFieldTest.php b/tests/php/Forms/FormFieldTest.php index 0611999e6e0..0fc0e2592cf 100644 --- a/tests/php/Forms/FormFieldTest.php +++ b/tests/php/Forms/FormFieldTest.php @@ -19,7 +19,7 @@ use SilverStripe\Forms\NullableField; use SilverStripe\Forms\PopoverField; use SilverStripe\Forms\PrintableTransformation_TabSet; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\SelectionGroup; use SilverStripe\Forms\SelectionGroup_Item; use SilverStripe\Forms\Tab; @@ -40,7 +40,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use SilverStripe\Core\Injector\Injector; use SilverStripe\Forms\ConfirmedPasswordField; -use SilverStripe\Forms\FieldsValidator; +use SilverStripe\Forms\FormFieldsValidator; use SilverStripe\Forms\NumericField; use SilverStripe\Forms\CheckboxField_Readonly; use SilverStripe\VersionedAdmin\Forms\DiffField; @@ -532,7 +532,7 @@ public function testSetSchemaState() public function testGetSchemaStateWithFormValidation() { $field = new FormField('MyField', 'My Field'); - $validator = new RequiredFields('MyField'); + $validator = new RequiredFieldsValidator('MyField'); $form = new Form(null, 'TestForm', new FieldList($field), new FieldList(), $validator); $form->validationResult(); $schema = $field->getSchemaState(); @@ -547,7 +547,7 @@ public function testValidationExtensionHooks() /** @var TextField|FieldValidationExtension $field */ $field = new TextField('Test'); $field->setMaxLength(5); - $form = new Form(null, 'test', new FieldList($field), new FieldList(), new FieldsValidator()); + $form = new Form(null, 'test', new FieldList($field), new FieldList(), new FormFieldsValidator()); $form->disableSecurityToken(); $field->setValue('IAmLongerThan5Characters'); diff --git a/tests/php/Forms/FormSchemaTest.php b/tests/php/Forms/FormSchemaTest.php index ed78a8ef70c..c7d4f806e8d 100644 --- a/tests/php/Forms/FormSchemaTest.php +++ b/tests/php/Forms/FormSchemaTest.php @@ -11,7 +11,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\TextField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\PopoverField; use SilverStripe\Forms\FormField; @@ -141,7 +141,7 @@ public function testGetStateWithFieldValidationErrors() { $fields = new FieldList(new TextField('Title')); $actions = new FieldList(); - $validator = new RequiredFields('Title'); + $validator = new RequiredFieldsValidator('Title'); $form = new Form(null, 'TestForm', $fields, $actions, $validator); $form->clearMessage(); $form->loadDataFrom( @@ -240,7 +240,7 @@ public function testSchemaValidation() new CurrencyField("Money") ), new FieldList(), - new RequiredFields('Name') + new RequiredFieldsValidator('Name') ); $formSchema = new FormSchema(); $schema = $formSchema->getSchema($form); diff --git a/tests/php/Forms/FormTest/ControllerWithSpecialSubmittedValueFields.php b/tests/php/Forms/FormTest/ControllerWithSpecialSubmittedValueFields.php index 538261bd6c9..0379840a4dc 100644 --- a/tests/php/Forms/FormTest/ControllerWithSpecialSubmittedValueFields.php +++ b/tests/php/Forms/FormTest/ControllerWithSpecialSubmittedValueFields.php @@ -12,7 +12,7 @@ use SilverStripe\Forms\FormAction; use SilverStripe\Forms\MoneyField; use SilverStripe\Forms\NumericField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\TextField; use SilverStripe\Core\Validation\ValidationException; use SilverStripe\Core\Validation\ValidationResult; @@ -69,7 +69,7 @@ public function Form() new FieldList( FormAction::create('doSubmit') ), - new RequiredFields( + new RequiredFieldsValidator( 'SomeRequiredField' ) ); diff --git a/tests/php/Forms/FormTest/TestController.php b/tests/php/Forms/FormTest/TestController.php index a9ca0a1259d..cc3beb48a44 100644 --- a/tests/php/Forms/FormTest/TestController.php +++ b/tests/php/Forms/FormTest/TestController.php @@ -11,7 +11,7 @@ use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\NumericField; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\TextField; use SilverStripe\Core\Validation\ValidationException; use SilverStripe\Core\Validation\ValidationResult; @@ -66,7 +66,7 @@ public function Form() FormAction::create('doSubmitActionExempt') ->setValidationExempt(true) ), - new RequiredFields( + new RequiredFieldsValidator( 'Email', 'SomeRequiredField' ) diff --git a/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php b/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php index c5f33364065..26ddade234c 100644 --- a/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php +++ b/tests/php/Forms/GridField/GridFieldDetailFormTest/Person.php @@ -5,7 +5,7 @@ use SilverStripe\Dev\TestOnly; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObjectSchema; @@ -67,7 +67,7 @@ public function getCMSFields() public function getCMSValidator() { - return new RequiredFields( + return new RequiredFieldsValidator( [ 'FirstName', 'Surname' diff --git a/tests/php/Forms/GridField/GridFieldTest.php b/tests/php/Forms/GridField/GridFieldTest.php index d80a9a70c62..4890b169b21 100644 --- a/tests/php/Forms/GridField/GridFieldTest.php +++ b/tests/php/Forms/GridField/GridFieldTest.php @@ -22,7 +22,7 @@ use SilverStripe\Forms\GridField\GridState; use SilverStripe\Forms\GridField\GridState_Component; use SilverStripe\Forms\GridField\GridState_Data; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\RequiredFieldsValidator; use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader; use SilverStripe\Forms\Tests\GridField\GridFieldTest\Component; use SilverStripe\Forms\Tests\GridField\GridFieldTest\Component2; @@ -551,7 +551,7 @@ public function testValidationMessageInOutput() $gridField->setMessage(null); // A form that passes validation should not display a validation error in the FieldHolder output. - $form->setValidator(new RequiredFields()); + $form->setValidator(new RequiredFieldsValidator()); $form->validationResult(); $gridfieldOutput = $gridField->FieldHolder(); $this->assertStringNotContainsString('