Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends Symfony\Component\Validator\Constraint
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     if (is_array($options)) {
         $options = array_merge($options, array('pattern' => self::PATTERN));
     } else {
         $options = self::PATTERN;
     }
     parent::__construct($options);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct($options = null)
 {
     $pattern = 'production' == APPLICATION_ENV ? self::PRODUCTION_PATTERN : self::DEVELOPMENT_PATTERN;
     if (is_array($options)) {
         $options = array_merge($options, array('pattern' => $pattern));
     } else {
         $options = $pattern;
     }
     parent::__construct($options);
 }
Exemple #3
0
 public function testGetCustomHtmlPattern()
 {
     $constraint = new Regex(array('pattern' => '((?![0-9]$|[a-z]+).)*', 'htmlPattern' => 'foobar'));
     $this->assertSame('((?![0-9]$|[a-z]+).)*', $constraint->pattern);
     $this->assertSame('foobar', $constraint->getHtmlPattern());
 }
Exemple #4
0
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid client_secret.', 'pattern' => '/^([\\x20-\\x7E]*)$/'], (array) $options));
 }
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid error_description.', 'pattern' => '/^([\\x21\\x22-\\x5B\\x5D-\\x7E]+)$/'], (array) $options));
 }
Exemple #6
0
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid expires_in.', 'pattern' => '/^([0-9]+)$/'], $options));
 }
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid refresh_token.', 'pattern' => '/^([\\x20-\\x7E]+)$/'], (array) $options));
 }
Exemple #8
0
 public function testHtmlPattern()
 {
     // Specified htmlPattern
     $constraint = new Regex(array('pattern' => '/^[a-z]+$/i', 'htmlPattern' => '[a-zA-Z]+'));
     $this->assertEquals('[a-zA-Z]+', $constraint->getHtmlPattern());
     // Disabled htmlPattern
     $constraint = new Regex(array('pattern' => '/^[a-z]+$/i', 'htmlPattern' => false));
     $this->assertNull($constraint->getHtmlPattern());
     // Cannot be converted
     $constraint = new Regex(array('pattern' => '/^[a-z]+$/i'));
     $this->assertNull($constraint->getHtmlPattern());
     // Automatically converted
     $constraint = new Regex(array('pattern' => '/^[a-z]+$/'));
     $this->assertEquals('[a-z]+', $constraint->getHtmlPattern());
     // Automatically converted, adds .*
     $constraint = new Regex(array('pattern' => '/[a-z]+/'));
     $this->assertEquals('.*[a-z]+.*', $constraint->getHtmlPattern());
     // Dropped because of match=false
     $constraint = new Regex(array('pattern' => '/[a-z]+/', 'match' => false));
     $this->assertNull($constraint->getHtmlPattern());
 }
Exemple #9
0
 /**
  * @param mixed $options
  * @return self
  */
 public function __construct($options = null)
 {
     $options['pattern'] = sprintf(self::VALIDATION_PATTERN, $this->buildPattern($this->getCountryPatterns()));
     parent::__construct($options);
 }
 public function testConstraintGetDefaultOption()
 {
     $constraint = new Regex(array('pattern' => '/^[0-9]+$/'));
     $this->assertEquals('pattern', $constraint->getDefaultOption());
 }
Exemple #11
0
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid password.', 'pattern' => '/^([\\x09\\x20-\\x7E\\x80-\\x{D7FF}\\x{E000}-\\x{FFFD}\\x{10000}-\\x{10FFFF}]*)$/u'], (array) $options));
 }
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid response_type.', 'pattern' => '/^([a-z0-9\\_]+)$/'], (array) $options));
 }
Exemple #13
0
 public function __construct($options = null)
 {
     return parent::__construct(array_merge(['message' => 'This is not a valid scope.', 'pattern' => '/^([\\x21\\x22-\\x5B\\x5D-\\x7E]+(?:\\s*[\\x21\\x22-\\x5B\\x5D-\\x7E]+(?R)*)*)$/'], (array) $options));
 }