mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4294 from tractorcow/pulls/4.0/make-validate-public
API make DataObject::validate public
This commit is contained in:
commit
3e2fe2b751
@ -917,7 +917,7 @@ class File extends DataObject {
|
||||
return $labels;
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
if($this->config()->apply_restrictions_to_admin || !Permission::check('ADMIN')) {
|
||||
// Extension validation
|
||||
// TODO Merge this with Upload_Validator
|
||||
|
@ -326,7 +326,7 @@ class Folder extends File {
|
||||
}
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@ class FormField extends RequestHandler {
|
||||
* Validation method each {@link FormField} subclass should implement,
|
||||
* determining whether the field is valid or not based on the value.
|
||||
*
|
||||
* @param Validator $validator
|
||||
* @param Validator
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate($validator) {
|
||||
|
@ -1063,7 +1063,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @see {@link ValidationResult}
|
||||
* @return ValidationResult
|
||||
*/
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
$result = ValidationResult::create();
|
||||
$this->extend('validate', $result);
|
||||
return $result;
|
||||
@ -1075,7 +1075,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return ValidationResult
|
||||
*/
|
||||
public function doValidate() {
|
||||
// validate will be public in 4.0
|
||||
Deprecation::notice('5.0', 'Use validate');
|
||||
return $this->validate();
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ class Group extends DataObject {
|
||||
$this->setField("Code", Convert::raw2url($val));
|
||||
}
|
||||
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
$result = parent::validate();
|
||||
|
||||
// Check if the new group hierarchy would add certain "privileged permissions",
|
||||
|
@ -1487,7 +1487,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Validate this member object.
|
||||
*/
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
$valid = parent::validate();
|
||||
|
||||
if(!$this->ID || $this->isChanged('Password')) {
|
||||
|
@ -20,7 +20,7 @@ class PermissionRoleCode extends DataObject {
|
||||
"Role" => "PermissionRole",
|
||||
);
|
||||
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
$result = parent::validate();
|
||||
|
||||
// Check that new code doesn't increase privileges, unless an admin is editing.
|
||||
|
@ -103,18 +103,18 @@ class FileTest extends SapphireTest {
|
||||
|
||||
// Invalid ext
|
||||
$file->Name = 'asdf.php';
|
||||
$v = $file->doValidate();
|
||||
$v = $file->validate();
|
||||
$this->assertFalse($v->valid());
|
||||
$this->assertContains('Extension is not allowed', $v->message());
|
||||
|
||||
// Valid ext
|
||||
$file->Name = 'asdf.txt';
|
||||
$v = $file->doValidate();
|
||||
$v = $file->validate();
|
||||
$this->assertTrue($v->valid());
|
||||
|
||||
// Capital extension is valid as well
|
||||
$file->Name = 'asdf.TXT';
|
||||
$v = $file->doValidate();
|
||||
$v = $file->validate();
|
||||
$this->assertTrue($v->valid());
|
||||
|
||||
Config::inst()->remove('File', 'allowed_extensions');
|
||||
|
@ -1821,7 +1821,7 @@ class DataObjectTest_ValidatedObject extends DataObject implements TestOnly {
|
||||
'Name' => 'Varchar(50)'
|
||||
);
|
||||
|
||||
protected function validate() {
|
||||
public function validate() {
|
||||
if(!empty($this->Name)) {
|
||||
return new ValidationResult();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user