/** * @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; }
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; }
private function __construct($repositoryName) { Ensure::string($repositoryName); Ensure::notBlank($repositoryName); Ensure::regex($repositoryName, '/^[a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\.]+$/'); $this->repositoryName = $repositoryName; }
/** * 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'); }
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+/'); }
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+/'); }
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+/'); } }
/** * __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(); }
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; } }
/** * {@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']); } }
private function validateInput(string $input) { Assertion::regex($input, '/^[\\(\\)]+$/', 'Input must only consist of \'(\' or \')\''); }
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; }
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+/'); }
public function __construct($value) { Assertion::regex($value, '/^.{4,}$/', 'Password must be at least 4 characters'); $this->value = $value; }
public function __construct($value) { Assertion::regex($value, '/^[a-z]{3,16}$/', 'Username accepts only lowercase letters'); $this->value = (string) $value; }
private function validateInput(string $input) { Assertion::regex($input, '/^[\\^><v]+$/', "Input must only consist these characters: '<', '^', '>', 'v"); }
/** * @Then /^I should see that config$/ */ public function iShouldSeeThatConfig() { foreach ((array) $this->config as $key => $value) { Assertion::regex($this->output, '/' . preg_quote("[{$key}]") . '/'); } }
public function testInvalidRegexValueNotString() { $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_STRING); Assertion::regex(array("foo"), "(bar)"); }
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); }
/** * @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./'); }
/** * Create a new Username * * @param string $username * @return void */ public function __construct($value) { Assertion::regex($value, '/^[\\pL\\pM\\pN_-]+$/u'); $this->value = $value; }
/** * @Then /^I should see "([^"]*)"$/ */ public function iShouldSee($arg1) { Assertion::regex($this->output, '/' . preg_quote($arg1) . '/'); }