Skip to content

Commit

Permalink
MNT Add custom validator for test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Nov 9, 2023
1 parent a5aeaa3 commit 62e771e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\Versioned\Versioned;
use RelationFieldsTestPage;
use GridFieldTestPage;
use SilverStripe\Forms\RequiredFields;

/**
*
Expand Down Expand Up @@ -100,6 +101,13 @@ public function getCMSFields()
return $fields;
}

public function getCMSValidator()
{
return new RequiredFields(
['Name']
);
}

public function validate()
{
$result = parent::validate();
Expand Down
8 changes: 8 additions & 0 deletions code/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\Assets\Image;
use SilverStripe\Forms\EmailField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\RequiredFields;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\Connect\MySQLSchemaManager;
use SilverStripe\ORM\DataObject;
Expand Down Expand Up @@ -141,6 +142,13 @@ public function requireDefaultRecords()
srand();
}

public function getCMSValidator()
{
return new RequiredFields(
['Name']
);
}

public function validate()
{
$result = parent::validate();
Expand Down

0 comments on commit 62e771e

Please sign in to comment.