merged branch ajgarlag/fix-issn-option (PR #7804)

This PR was merged into the master branch.

Discussion
----------

[Validator] Rename requireHyphens to requireHyphen for Issn constraint

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

While writing the documentation for the new Issn validator submitted yesterday at https://github.com/symfony/symfony/pull/7756, I've realized that the option ```requireHyphens``` should be renamed to ```requireHyphen``` because only one hyphen is allowed in the ISSN value.

Commits
-------

94173ec Rename requireHyphens to requireHyphen for Issn constraint
This commit is contained in:
Fabien Potencier 2013-04-22 20:53:05 +02:00
commit 47b53c3af7
3 changed files with 4 additions and 4 deletions

View File

@ -22,5 +22,5 @@ class Issn extends Constraint
{
public $invalidMessage = 'This value is not a valid ISSN.';
public $caseSensitive = false;
public $requireHyphens = false;
public $requireHyphen = false;
}

View File

@ -38,7 +38,7 @@ class IssnValidator extends ConstraintValidator
}
// Compose regex pattern
$digitsPattern = $constraint->requireHyphens ? '\d{4}-\d{3}' : '\d{4}-?\d{3}';
$digitsPattern = $constraint->requireHyphen ? '\d{4}-\d{3}' : '\d{4}-?\d{3}';
$checksumPattern = $constraint->caseSensitive ? '[\d|X]' : '[\d|X|x]';
$pattern = "/^".$digitsPattern.$checksumPattern."$/";

View File

@ -153,9 +153,9 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getValidNonHyphenatedIssn
*/
public function testRequireHyphensIssns($issn)
public function testRequireHyphenIssns($issn)
{
$constraint = new Issn(array('requireHyphens' => true));
$constraint = new Issn(array('requireHyphen' => true));
$this->context
->expects($this->once())
->method('addViolation')