diff --git a/src/Forms/FieldsValidator.php b/src/Forms/FieldsValidator.php index 5a70dd76f7e..9a49e1aa2b7 100644 --- a/src/Forms/FieldsValidator.php +++ b/src/Forms/FieldsValidator.php @@ -3,6 +3,7 @@ namespace SilverStripe\Forms; use SilverStripe\Dev\Deprecation; +use SilverStripe\Forms\Validation\Validator; /** * Validates the internal state of all fields in the form. 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 5d25b4f543f..e2c4ed8751e 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -20,6 +20,8 @@ use SilverStripe\View\AttributesHTML; use SilverStripe\View\SSViewer; use SilverStripe\Model\ModelData; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; +use SilverStripe\Forms\Validation\Validator; /** * Base class for all forms. @@ -297,7 +299,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/GridField/GridFieldDetailForm.php b/src/Forms/GridField/GridFieldDetailForm.php index 544f6221f3c..cff6eaddfd4 100644 --- a/src/Forms/GridField/GridFieldDetailForm.php +++ b/src/Forms/GridField/GridFieldDetailForm.php @@ -15,7 +15,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldsValidator; -use SilverStripe\Forms\Validator; +use SilverStripe\Forms\Validation\Validator; use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataObject; use SilverStripe\Model\ModelData; 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/CompositeValidator.php b/src/Forms/Validation/CompositeValidator.php similarity index 94% rename from src/Forms/CompositeValidator.php rename to src/Forms/Validation/CompositeValidator.php index 8864168d348..5bac807d8b6 100644 --- a/src/Forms/CompositeValidator.php +++ b/src/Forms/Validation/CompositeValidator.php @@ -1,6 +1,6 @@ addValidator(RequiredFields::create(['MyRequiredField'])); + * $compositeValidator->addValidator(RequiredFieldsValidator::create(['MyRequiredField'])); * * return $compositeValidator * } @@ -29,7 +29,7 @@ * * protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void * { - * $compositeValidator->addValidator(RequiredFields::create(['AdditionalContent'])); + * $compositeValidator->addValidator(RequiredFieldsValidator::create(['AdditionalContent'])); * } * @deprecated 5.4.0 Will be renamed to SilverStripe\Forms\Validation\CompositeValidator */ @@ -106,7 +106,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 @@ -156,7 +156,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. @@ -181,7 +181,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/RequiredFields.php b/src/Forms/Validation/RequiredFieldsValidator.php similarity index 98% rename from src/Forms/RequiredFields.php rename to src/Forms/Validation/RequiredFieldsValidator.php index 0ec173f5c1e..51988cd6d17 100644 --- a/src/Forms/RequiredFields.php +++ b/src/Forms/Validation/RequiredFieldsValidator.php @@ -1,6 +1,6 @@ addValidator(RequiredFields::create([ + $validator->addValidator(RequiredFieldsValidator::create([ 'Title' ])); diff --git a/src/Security/LogoutForm.php b/src/Security/LogoutForm.php index 5b12c2c3563..6f4588d9d11 100644 --- a/src/Security/LogoutForm.php +++ b/src/Security/LogoutForm.php @@ -9,7 +9,7 @@ use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\HiddenField; -use SilverStripe\Forms\Validator; +use SilverStripe\Forms\Validation\Validator; /** * Log out form to display to users who arrive at 'Security/logout' without a diff --git a/src/Security/Member.php b/src/Security/Member.php index 1e025d5a159..7707df74ee2 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -15,7 +15,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\TestMailer; use SilverStripe\Forms\CheckboxField; -use SilverStripe\Forms\CompositeValidator; +use SilverStripe\Forms\Validation\CompositeValidator; use SilverStripe\Forms\ConfirmedPasswordField; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldList; @@ -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..8273020748f 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\Validation\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..7ad2bc354a5 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\Validation\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..574106976f0 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\Validation\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..2c7e75a3775 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\Validation\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..d15f60599ab 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\Validation\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..da181e9bbd8 100644 --- a/tests/php/Forms/CompositeValidatorTest.php +++ b/tests/php/Forms/CompositeValidatorTest.php @@ -8,10 +8,10 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\Tests\ValidatorTest\TestValidator; use SilverStripe\Forms\TextField; -use SilverStripe\Forms\CompositeValidator; +use SilverStripe\Forms\Validation\CompositeValidator; /** * @package framework @@ -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..6c8cee8cf66 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\Validation\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..13543e65751 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\Validation\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..7f60339a177 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\Validation\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..4dc5da9e8b4 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\Validation\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..2e87284a7c3 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\Validation\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/TestController.php b/tests/php/Forms/EmailFieldTest/TestController.php index fd01418e34f..a0ae0ca3dc1 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\Validation\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/FileFieldTest.php b/tests/php/Forms/FileFieldTest.php index 3529b5eea1f..aa863cf049d 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\Validation\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 647c1adcfec..ba8438c3ffc 100644 --- a/tests/php/Forms/FormFieldTest.php +++ b/tests/php/Forms/FormFieldTest.php @@ -20,7 +20,7 @@ use SilverStripe\Forms\NullableField; use SilverStripe\Forms\PopoverField; use SilverStripe\Forms\PrintableTransformation_TabSet; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use SilverStripe\Forms\SelectionGroup; use SilverStripe\Forms\SelectionGroup_Item; use SilverStripe\Forms\Tab; @@ -533,7 +533,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(); diff --git a/tests/php/Forms/FormSchemaTest.php b/tests/php/Forms/FormSchemaTest.php index ed78a8ef70c..1cc3a46fbd6 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\Validation\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..d16d59a8034 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\Validation\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..1aac455062d 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\Validation\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..ce97268c0e6 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\Validation\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..7dc479356e1 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\Validation\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('