Skip to content

Commit

Permalink
Merge branch '6.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Sep 20, 2017
2 parents d0f50d7 + 603892f commit 60f162a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
7 changes: 7 additions & 0 deletions eZ/Publish/Core/FieldType/Tests/StringLengthValidatorTest.php
Expand Up @@ -168,6 +168,7 @@ public function providerForValidateOK()
array('hello'),
array('hello!'),
array('0123456789'),
array('♔♕♖♗♘♙♚♛♜♝'),
);
}

Expand Down Expand Up @@ -228,6 +229,12 @@ public function providerForValidateKO()
'The string can not exceed %size% characters.',
array('%size%' => $this->getMaxStringLength()),
),
array(
'ABC♔',
'The string can not be shorter than %size% character.',
'The string can not be shorter than %size% characters.',
array('%size%' => $this->getMinStringLength()),
),
);
}

Expand Down
31 changes: 31 additions & 0 deletions eZ/Publish/Core/FieldType/Tests/TextLineTest.php
Expand Up @@ -544,6 +544,16 @@ public function provideValidDataForValidate()
),
new TextLineValue('lililili'),
),
array(
array(
'validatorConfiguration' => array(
'StringLengthValidator' => array(
'maxStringLength' => 10,
),
),
),
new TextLineValue('♔♕♖♗♘♙♚♛♜♝'),
),
);
}

Expand Down Expand Up @@ -685,6 +695,27 @@ public function provideInvalidDataForValidate()
),
),
),
array(
array(
'validatorConfiguration' => array(
'StringLengthValidator' => array(
'minStringLength' => 5,
'maxStringLength' => 10,
),
),
),
new TextLineValue('ABC♔'),
array(
new ValidationError(
'The string can not be shorter than %size% character.',
'The string can not be shorter than %size% characters.',
array(
'%size%' => 5,
),
'text'
),
),
),
);
}
}
4 changes: 2 additions & 2 deletions eZ/Publish/Core/FieldType/TextLine/Type.php
Expand Up @@ -91,7 +91,7 @@ public function validate(FieldDefinition $fieldDefinition, SPIValue $fieldValue)
if (isset($constraints['maxStringLength']) &&
$constraints['maxStringLength'] !== false &&
$constraints['maxStringLength'] !== 0 &&
strlen($fieldValue->text) > $constraints['maxStringLength']) {
mb_strlen($fieldValue->text) > $constraints['maxStringLength']) {
$validationErrors[] = new ValidationError(
'The string can not exceed %size% character.',
'The string can not exceed %size% characters.',
Expand All @@ -105,7 +105,7 @@ public function validate(FieldDefinition $fieldDefinition, SPIValue $fieldValue)
if (isset($constraints['minStringLength']) &&
$constraints['minStringLength'] !== false &&
$constraints['minStringLength'] !== 0 &&
strlen($fieldValue->text) < $constraints['minStringLength']) {
mb_strlen($fieldValue->text) < $constraints['minStringLength']) {
$validationErrors[] = new ValidationError(
'The string can not be shorter than %size% character.',
'The string can not be shorter than %size% characters.',
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/FieldType/Validator/StringLengthValidator.php
Expand Up @@ -112,7 +112,7 @@ public function validate(BaseValue $value)

if ($this->constraints['maxStringLength'] !== false &&
$this->constraints['maxStringLength'] !== 0 &&
strlen($value->text) > $this->constraints['maxStringLength']) {
mb_strlen($value->text) > $this->constraints['maxStringLength']) {
$this->errors[] = new ValidationError(
'The string can not exceed %size% character.',
'The string can not exceed %size% characters.',
Expand All @@ -124,7 +124,7 @@ public function validate(BaseValue $value)
}
if ($this->constraints['minStringLength'] !== false &&
$this->constraints['minStringLength'] !== 0 &&
strlen($value->text) < $this->constraints['minStringLength']) {
mb_strlen($value->text) < $this->constraints['minStringLength']) {
$this->errors[] = new ValidationError(
'The string can not be shorter than %size% character.',
'The string can not be shorter than %size% characters.',
Expand Down

0 comments on commit 60f162a

Please sign in to comment.