N°931: Fix integrity controls (tag code length)

This commit is contained in:
Eric
2018-09-17 11:59:37 +02:00
parent ec38473d88
commit f1a8bb08da
4 changed files with 6 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ abstract class TagSetFieldData extends cmdbAbstractObject
// Check that code and labels are uniques // Check that code and labels are uniques
$sTagCode = $this->Get('tag_code'); $sTagCode = $this->Get('tag_code');
// Check tag_code syntax // Check tag_code syntax
if (!preg_match("@^[a-zA-Z0-9]{1,20}$@", $sTagCode)) if (!preg_match("@^[a-zA-Z0-9]{3,20}$@", $sTagCode))
{ {
$this->m_aCheckIssues[] = Dict::S('Core:TagSetFieldData:ErrorTagCodeSyntax'); $this->m_aCheckIssues[] = Dict::S('Core:TagSetFieldData:ErrorTagCodeSyntax');
} }

View File

@@ -919,7 +919,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:TagSetFieldData+' => '', 'Class:TagSetFieldData+' => '',
'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Used tags cannot be deleted', 'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Used tags cannot be deleted',
'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Tags codes or labels must be unique', 'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Tags codes or labels must be unique',
'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code should match [a-zA-Z0-9]{1,20} syntax', 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code should contain between 3 and 20 alphanumeric characters',
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label should not contain | nor be empty', 'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label should not contain | nor be empty',
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags code cannot be changed', 'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags code cannot be changed',
)); ));

View File

@@ -767,7 +767,7 @@ Opérateurs :<br/>
'Core:Validator:MustSelectOne' => 'Veuillez choisir une valeur', 'Core:Validator:MustSelectOne' => 'Veuillez choisir une valeur',
'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Impossible de supprimer une étiquette utilisée', 'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Impossible de supprimer une étiquette utilisée',
'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Les codes et noms des étiquettes doivent être unique', 'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Les codes et noms des étiquettes doivent être unique',
'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Le code de l\'étiquette doit avoir la syntaxe suivante : [a-zA-Z0-9]{1,20}', 'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Le code de l\'étiquette doit contenir entre 3 et 20 caractères alphanumériques.',
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Le nom de l\'étiquette ne doit pas être vide ni contenir le caractère \'|\'', 'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Le nom de l\'étiquette ne doit pas être vide ni contenir le caractère \'|\'',
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Le code de l\'étiquette ne peut pas être changé', 'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Le code de l\'étiquette ne peut pas être changé',
)); ));

View File

@@ -165,7 +165,9 @@ class TagSetFieldDataTest extends ItopDataTestCase
'No -' => array('tag-1'), 'No -' => array('tag-1'),
'No %' => array('tag%1'), 'No %' => array('tag%1'),
'Less than 21 chars' => array('012345678901234567890'), 'Less than 21 chars' => array('012345678901234567890'),
'At least one char' => array(''), 'At least 3 chars' => array(''),
'At least 3 chars 1' => array('a'),
'At least 3 chars 2' => array('ab'),
'No #' => array('#tag'), 'No #' => array('#tag'),
'No !' => array('tag!'), 'No !' => array('tag!'),
); );