regex() public static method

Assert that value matches a regex
public static regex ( mixed $value, string $pattern, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$pattern string
$message string | null
$propertyPath string | null
return boolean
コード例 #1
0
ファイル: Locale.php プロジェクト: gingerpayments/ginger-php
 /**
  * @param string $value
  */
 private function __construct($value)
 {
     if (!empty($value)) {
         Guard::regex($value, '/^[a-z]{2}(_[A-Z]{2})?$/', "Locale is invalid: " . $value);
     }
     $this->value = $value;
 }
コード例 #2
0
ファイル: XmlPath.php プロジェクト: metasyntactical/xml-tools
 private function setPath($path)
 {
     Assertion::string($path);
     Assertion::regex($path, '|(?mi-Us)^(/[a-zA-Z][a-zA-Z0-9_-]*)+(/@[a-zA-Z][a-zA-Z0-9_-]*)?$|');
     $this->path = $path;
     return $this;
 }
コード例 #3
0
 private function __construct($repositoryName)
 {
     Ensure::string($repositoryName);
     Ensure::notBlank($repositoryName);
     Ensure::regex($repositoryName, '/^[a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\.]+$/');
     $this->repositoryName = $repositoryName;
 }
コード例 #4
0
ファイル: ApiBpm.php プロジェクト: agoalofalife/bpm-online
 /**
  * Checking input parameters for working with API BPM
  * @param $collection
  * @param $format
  */
 public function checkStartParameters($collection, $format)
 {
     $collection = ucfirst($collection);
     $format = mb_strtolower($format);
     \Assert\that($collection, 'The first parameter expects a string to the type of collection has BPM')->string();
     Assertion::regex($format, '~^json$|^xml$~', 'Expects parameter json or xml');
 }
コード例 #5
0
ファイル: ProjectionEvent.php プロジェクト: honeybee/honeybee
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::regex($this->projection_type, '#^([a-z][a-z_-]+(?<!_-)\\.){2}[a-z][a-z_]+(?<!_)::projection\\.[a-z][a-z_]+(?<!_)$#');
     Assertion::isArray($this->data);
     Assertion::regex($this->projection_identifier, '/[\\w\\.\\-_]{1,128}\\-\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12}\\-\\w{2}_\\w{2}\\-\\d+/');
 }
コード例 #6
0
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::regex($this->aggregate_root_type, '#^([a-z][a-z_-]+(?<![_-])\\.){2}[a-z][a-z_-]+(?<![_-])$#');
     Assertion::integer($this->seq_number);
     Assertion::isInstanceOf($this->embedded_entity_events, EmbeddedEntityEventList::CLASS);
     Assertion::regex($this->aggregate_root_identifier, '/[\\w\\.\\-_]{1,128}\\-\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12}\\-\\w{2}_\\w{2}\\-\\d+/');
 }
コード例 #7
0
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::keyExists($this->data, 'parent_node_id');
     Assertion::string($this->data['parent_node_id']);
     if ($this->data['parent_node_id'] !== '') {
         Assertion::regex($this->data['parent_node_id'], '/[\\w\\.\\-_]{1,128}\\-\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12}\\-\\w{2}_\\w{2}\\-\\d+/');
     }
 }
コード例 #8
0
ファイル: Project.php プロジェクト: mykanoa/kanoa
 /**
  * __construct()
  *
  * @param string $name Project name
  */
 public function __construct($name)
 {
     Assertion::string($name);
     Assertion::maxLength($name, 20, 'Project key exceeds max allowed chars');
     Assertion::regex($name, '/^[a-z0-9\\-]*$/', 'Project key does not match expected format');
     $this->name = $name;
     $this->environments = new \SplObjectStorage();
     $this->servers = new \SplObjectStorage();
     $this->tasks = new \SplObjectStorage();
 }
コード例 #9
0
ファイル: Expectation.php プロジェクト: alexbilbie/fizzfuzz
 public function evaluate($expected, $message)
 {
     switch ($this->strategy) {
         case 0:
             $message = sprintf($message, $this->value, $expected);
             Assertion::same($this->value, $expected, $message);
             break;
         case 1:
             $message = sprintf('Expected `%s` to match regex `%s`, but it didn\'t`', $expected, $this->value);
             Assertion::regex($expected, $this->value, $message);
             break;
         case 2:
             $message = sprintf($message, $this->value, gettype($expected));
             Assertion::same($this->value, gettype($expected), $message);
             break;
     }
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 public function check(ClientInterface $client, array $registration_parameters)
 {
     if (!$this->hasScopeManager()) {
         return;
     }
     if (array_key_exists('scope', $registration_parameters)) {
         Assertion::regex($registration_parameters['scope'], '/^[\\x20\\x23-\\x5B\\x5D-\\x7E]+$/', 'Invalid characters found in the "scope" parameter.');
         $client->set('scope', $registration_parameters['scope']);
     }
     if (array_key_exists('scope_policy', $registration_parameters)) {
         Assertion::inArray($registration_parameters['scope_policy'], $this->getScopeManager()->getSupportedScopePolicies(), sprintf('The scope policy "%s" is not supported. Please choose one of the following policy: "%s".', $registration_parameters['scope_policy'], json_encode($this->getScopeManager()->getSupportedScopePolicies())));
         $client->set('scope_policy', $registration_parameters['scope_policy']);
     }
     /*
      * Should be handled by the scope policy itself
      */
     if (array_key_exists('default_scope', $registration_parameters)) {
         Assertion::regex($registration_parameters['default_scope'], '/^[\\x20\\x23-\\x5B\\x5D-\\x7E]+$/', 'Invalid characters found in the "default_scope" parameter.');
         $client->set('default_scope', $registration_parameters['default_scope']);
     }
 }
コード例 #11
0
ファイル: Day1.php プロジェクト: stefanotorresi/thorr-advent
 private function validateInput(string $input)
 {
     Assertion::regex($input, '/^[\\(\\)]+$/', 'Input must only consist of \'(\' or \')\'');
 }
コード例 #12
0
ファイル: Filename.php プロジェクト: bakgat/notos
 public function __construct($value)
 {
     //Filenames must be md5 followed by jpg, gif, bmp, png
     Assertion::regex($value, '/^[a-f0-9]{32}\\.(jpg|png|gif|bmp)^/i');
     $this->value = $value;
 }
コード例 #13
0
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::integer($this->known_revision);
     Assertion::regex($this->aggregate_root_identifier, '/[\\w\\.\\-_]{1,128}\\-\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12}\\-\\w{2}_\\w{2}\\-\\d+/');
 }
コード例 #14
0
 public function __construct($value)
 {
     Assertion::regex($value, '/^.{4,}$/', 'Password must be at least 4 characters');
     $this->value = $value;
 }
コード例 #15
0
 public function __construct($value)
 {
     Assertion::regex($value, '/^[a-z]{3,16}$/', 'Username accepts only lowercase letters');
     $this->value = (string) $value;
 }
コード例 #16
0
ファイル: Day3.php プロジェクト: stefanotorresi/thorr-advent
 private function validateInput(string $input)
 {
     Assertion::regex($input, '/^[\\^><v]+$/', "Input must only consist these characters: '<', '^', '>', 'v");
 }
コード例 #17
0
 /**
  * @Then /^I should see that config$/
  */
 public function iShouldSeeThatConfig()
 {
     foreach ((array) $this->config as $key => $value) {
         Assertion::regex($this->output, '/' . preg_quote("[{$key}]") . '/');
     }
 }
コード例 #18
0
ファイル: AssertTest.php プロジェクト: GerDner/luck-docker
 public function testInvalidRegexValueNotString()
 {
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_STRING);
     Assertion::regex(array("foo"), "(bar)");
 }
コード例 #19
0
 protected function guardRequiredState()
 {
     parent::guardRequiredState();
     Assertion::regex($this->aggregate_root_type, '#^([a-z][a-z_-]+(?<![_-])\\.){2}[a-z][a-z_-]+(?<![_-])$#');
     Assertion::notNull($this->embedded_entity_commands);
 }
コード例 #20
0
 /**
  * @Then the process should be skipped
  */
 public function ensureSkippedProcess()
 {
     Assertion::regex($this->tester->getDisplay(), '/Validated 1 manager, 0 needed schema appliance, 1 was in sync./');
 }
コード例 #21
0
ファイル: Username.php プロジェクト: snb4crazy/cribbb
 /**
  * Create a new Username
  *
  * @param string $username
  * @return void
  */
 public function __construct($value)
 {
     Assertion::regex($value, '/^[\\pL\\pM\\pN_-]+$/u');
     $this->value = $value;
 }
コード例 #22
0
 /**
  * @Then /^I should see "([^"]*)"$/
  */
 public function iShouldSee($arg1)
 {
     Assertion::regex($this->output, '/' . preg_quote($arg1) . '/');
 }