[Validator] Rename issn constraint message option to be consistent with all constraints having a single message option
This commit is contained in:
parent
06d5fb171f
commit
57c724a37f
@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
*/
|
*/
|
||||||
class Issn extends Constraint
|
class Issn extends Constraint
|
||||||
{
|
{
|
||||||
public $invalidMessage = 'This value is not a valid ISSN.';
|
public $message = 'This value is not a valid ISSN.';
|
||||||
public $caseSensitive = false;
|
public $caseSensitive = false;
|
||||||
public $requireHyphen = false;
|
public $requireHyphen = false;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class IssnValidator extends ConstraintValidator
|
|||||||
$pattern = "/^".$digitsPattern.$checksumPattern."$/";
|
$pattern = "/^".$digitsPattern.$checksumPattern."$/";
|
||||||
|
|
||||||
if (!preg_match($pattern, $value)) {
|
if (!preg_match($pattern, $value)) {
|
||||||
$this->context->addViolation($constraint->invalidMessage);
|
$this->context->addViolation($constraint->message);
|
||||||
} else {
|
} else {
|
||||||
$digits = str_split(strtoupper(str_replace('-', '', $value)));
|
$digits = str_split(strtoupper(str_replace('-', '', $value)));
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class IssnValidator extends ConstraintValidator
|
|||||||
$checksum = 'X' == reset($digits) ? 10 : (int) reset($digits);
|
$checksum = 'X' == reset($digits) ? 10 : (int) reset($digits);
|
||||||
|
|
||||||
if (0 != ($sum + $checksum) % 11) {
|
if (0 != ($sum + $checksum) % 11) {
|
||||||
$this->context->addViolation($constraint->invalidMessage);
|
$this->context->addViolation($constraint->message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->context
|
$this->context
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('addViolation')
|
->method('addViolation')
|
||||||
->with($constraint->invalidMessage);
|
->with($constraint->message);
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->context
|
$this->context
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('addViolation')
|
->method('addViolation')
|
||||||
->with($constraint->invalidMessage);
|
->with($constraint->message);
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->context
|
$this->context
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('addViolation')
|
->method('addViolation')
|
||||||
->with($constraint->invalidMessage);
|
->with($constraint->message);
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->context
|
$this->context
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('addViolation')
|
->method('addViolation')
|
||||||
->with($constraint->invalidMessage);
|
->with($constraint->message);
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user