Skip to content

Commit

Permalink
Merge branch '6.0' into 6
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 9, 2024
2 parents e7f8b18 + 946ea39 commit 3e62b98
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Forms/CompositeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use InvalidArgumentException;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Dev\Deprecation;

/**
* CompositeValidator can contain between 0 and many different types of Validators. Each Validator is itself still
Expand All @@ -30,6 +31,7 @@
* {
* $compositeValidator->addValidator(RequiredFields::create(['AdditionalContent']));
* }
* @deprecated 5.4.0 Will be renamed to SilverStripe\Forms\Validation\CompositeValidator
*/
class CompositeValidator extends Validator
{
Expand All @@ -45,8 +47,12 @@ class CompositeValidator extends Validator
*/
public function __construct(array $validators = [])
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be renamed to SilverStripe\\Forms\\Validation\\CompositeValidator',
Deprecation::SCOPE_CLASS
);
$this->validators = array_values($validators ?? []);

parent::__construct();
}

Expand Down
14 changes: 14 additions & 0 deletions src/Forms/FieldsValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

namespace SilverStripe\Forms;

use SilverStripe\Dev\Deprecation;

/**
* Validates the internal state of all fields in the form.
*
* @deprecated 5.4.0 Will be replaced with functionality inside SilverStripe\Forms\Form::validate()
*/
class FieldsValidator extends Validator
{
public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be replaced with functionality inside SilverStripe\Forms\Form::validate()',
Deprecation::SCOPE_CLASS
);
parent::__construct();
}

public function php($data): bool
{
$fields = $this->form->Fields();
Expand Down
8 changes: 8 additions & 0 deletions src/Forms/RequiredFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Forms;

use SilverStripe\Core\ArrayLib;
use SilverStripe\Dev\Deprecation;

/**
* Required Fields allows you to set which fields need to be present before
Expand All @@ -11,6 +12,8 @@
*
* Validation is performed on a field by field basis through
* {@link FormField::validate}.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Forms\Validation\RequiredFieldsValidator
*/
class RequiredFields extends Validator
{
Expand Down Expand Up @@ -39,6 +42,11 @@ class RequiredFields extends Validator
*/
public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be renamed to SilverStripe\\Forms\\Validation\\RequiredFieldsValidator',
Deprecation::SCOPE_CLASS
);
$required = func_get_args();
if (isset($required[0]) && is_array($required[0])) {
$required = $required[0];
Expand Down
8 changes: 8 additions & 0 deletions src/Forms/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Dev\Deprecation;

/**
* This validation class handles all form and custom form validation through the use of Required
* fields. It relies on javascript for client-side validation, and marking fields after server-side
* validation. It acts as a visitor to individual form fields.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Forms\Validation\Validator
*/
abstract class Validator
{
Expand All @@ -20,6 +23,11 @@ abstract class Validator

public function __construct()
{
Deprecation::noticeWithNoReplacment(
'5.4.0',
'Will be renamed to SilverStripe\\Forms\\Validation\\Validator',
Deprecation::SCOPE_CLASS
);
$this->resetResult();
}

Expand Down

0 comments on commit 3e62b98

Please sign in to comment.