N°6414 Validator refactoring

New AbstractValidator class, with new method Validate
All existing validators are now children of AbstractRegexpValidator
Handle validators JS counterparts in renderers : only regexp validators are implemented client side
This commit is contained in:
Pierre Goiffon
2023-06-29 10:41:51 +02:00
parent 52049b7837
commit 6606af71ff
26 changed files with 348 additions and 247 deletions

View File

@@ -0,0 +1,28 @@
<?php
/*
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Test\UnitTest\Sources\Form\Validator;
use Combodo\iTop\Form\Field\StringField;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
class ValidatorTest extends ItopTestCase
{
public function testMandatoryValidator()
{
$oField = new StringField('test');
$oField->SetMandatory(true);
$oField->SetCurrentValue('there is a value !');
$bIsMandatoryFieldValidWithExistingValue = $oField->Validate();
$this->assertTrue($bIsMandatoryFieldValidWithExistingValue);
$oField->SetCurrentValue(null);
$bIsMandatoryFieldValidWithNoValue = $oField->Validate();
$this->assertFalse($bIsMandatoryFieldValidWithNoValue);
$this->assertNotEmpty($oField->GetErrorMessages());
}
}