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 2, 2024
1 parent 8f867be commit cca47b1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 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\RequiredFieldsValidator) validator:

```php
namespace App\Model;

use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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
4 changes: 2 additions & 2 deletions src/Models/EmailLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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
4 changes: 2 additions & 2 deletions src/Models/ExternalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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
4 changes: 2 additions & 2 deletions src/Models/FileLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use SilverStripe\Assets\File;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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
4 changes: 2 additions & 2 deletions src/Models/PhoneLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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
4 changes: 2 additions & 2 deletions src/Models/SiteTreeLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\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

0 comments on commit cca47b1

Please sign in to comment.