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 #355

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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"silverstripe/frameworktest": "^2",
"dnadesign/silverstripe-elemental": "^6",
"dnadesign/silverstripe-elemental": "6.x-dev",
"silverstripe/recipe-testing": "^4",
"silverstripe/standards": "^1",
"silverstripe/documentation-lint": "^1",
Expand Down
8 changes: 4 additions & 4 deletions docs/en/01_basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ class MyModel extends DataObject

Custom links can have validation set using standard [model validation](https://docs.silverstripe.org/en/developer_guides/forms/validation/#model-validation). This is true both for the validation of the link data itself, as well as validating relations to the `Link` class.

For example you can make sure you have a link in your `has_one` or `has_many` relation using a [`RequiredFields`](api:SilverStripe\Forms\RequiredFields) validator:
For example you can make sure you have a link in your `has_one` or `has_many` relation using a [`RequiredFieldsValidator`](api:SilverStripe\Forms\Validation\RequiredFieldsValidator) validator:

```php
namespace App\Model;

use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;
use SilverStripe\LinkField\Models\Link;
use SilverStripe\ORM\DataObject;

Expand All @@ -140,7 +140,7 @@ class MyModel extends DataObject
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['HasOneLink', 'HasManyLinks']));
$validator->addValidator(RequiredFieldsValidator::create(['HasOneLink', 'HasManyLinks']));
return $validator;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Models/EmailLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;

/**
* A link to an Email address.
Expand Down Expand Up @@ -39,7 +39,7 @@ public function getCMSFields(): FieldList
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['Email']));
$validator->addValidator(RequiredFieldsValidator::create(['Email']));
return $validator;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Models/ExternalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace SilverStripe\LinkField\Models;

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;
use SilverStripe\Forms\UrlField;

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ public function getCMSFields(): FieldList
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['ExternalUrl']));
$validator->addValidator(RequiredFieldsValidator::create(['ExternalUrl']));
return $validator;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Models/FileLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use SilverStripe\Assets\File;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;

/**
* A link to a File in the CMS
Expand Down Expand Up @@ -37,7 +37,7 @@ public function getCMSFields(): FieldList
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['File']));
$validator->addValidator(RequiredFieldsValidator::create(['File']));
return $validator;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Models/PhoneLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace SilverStripe\LinkField\Models;

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;

/**
* A link to a phone number
Expand Down Expand Up @@ -34,7 +34,7 @@ public function getCMSFields(): FieldList
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['Phone']));
$validator->addValidator(RequiredFieldsValidator::create(['Phone']));
return $validator;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Models/SiteTreeLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\RequiredFieldsValidator;
use SilverStripe\Forms\Tip;

/**
Expand Down Expand Up @@ -91,7 +91,7 @@ public function getCMSFields(): FieldList
public function getCMSCompositeValidator(): CompositeValidator
{
$validator = parent::getCMSCompositeValidator();
$validator->addValidator(RequiredFields::create(['PageID']));
$validator->addValidator(RequiredFieldsValidator::create(['PageID']));
return $validator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use SilverStripe\Dev\TestOnly;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\Validator;
use SilverStripe\Forms\Validation\CompositeValidator;
use SilverStripe\Forms\Validation\Validator;
use SilverStripe\LinkField\Models\Link;

class TestPhoneLink extends Link implements TestOnly
Expand Down
Loading