for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SLLH\IsoCodesValidator\Constraints;
use IsoCodes;
use SLLH\IsoCodesValidator\AbstractConstraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*
* @author Sullivan Senechal <[email protected]>
*/
final class ZipCode extends AbstractConstraint
{
const ALL = 'all';
public $country = self::ALL;
public $message = 'This value is not a valid ZIP code.';
* {@inheritdoc}
public function __construct($options = null)
parent::__construct($options);
if ($this->country != self::ALL && !in_array($this->country, IsoCodes\ZipCode::getAvailableCountries())) {
throw new ConstraintDefinitionException(sprintf(
'The option "country" must be one of "%s" or "all"',
implode('", "', IsoCodes\ZipCode::getAvailableCountries())
));
}
public function getIsoCodesVersion()
return '1.0.0';
public function getIsoCodesClass()
return IsoCodes\ZipCode::class;