本文整理汇总了PHP中Assert\Assertion::regex方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::regex方法的具体用法?PHP Assertion::regex怎么用?PHP Assertion::regex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::regex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @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: setPath
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: __construct
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: checkStartParameters
/**
* 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: guardRequiredState
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: guardRequiredState
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: guardRequiredState
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: __construct
/**
* __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: evaluate
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: check
/**
* {@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: validateInput
private function validateInput(string $input)
{
Assertion::regex($input, '/^[\\(\\)]+$/', 'Input must only consist of \'(\' or \')\'');
}
示例12: __construct
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: guardRequiredState
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: __construct
public function __construct($value)
{
Assertion::regex($value, '/^.{4,}$/', 'Password must be at least 4 characters');
$this->value = $value;
}
示例15: __construct
public function __construct($value)
{
Assertion::regex($value, '/^[a-z]{3,16}$/', 'Username accepts only lowercase letters');
$this->value = (string) $value;
}