Skip to content

Commit

Permalink
API Rename validator classes
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Dec 10, 2024
1 parent aa1c1c4 commit 44403e4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
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

0 comments on commit 44403e4

Please sign in to comment.