本文整理汇总了PHP中Respect\Validation\Validator::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::instance方法的具体用法?PHP Validator::instance怎么用?PHP Validator::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a new {@link LightInstruction}, verifying the action is valid and exactly two
* coordinates have been given.
*
* @param int $action {@link LightInstructionAction}
* @param Coordinate[] $coordinatePair two coordinates
* @return LightInstruction
* @throws \InvalidArgumentException
*/
public static function create($action, array $coordinatePair)
{
v::oneOf(v::equals(LightInstructionAction::TURN_ON), v::equals(LightInstructionAction::TURN_OFF), v::equals(LightInstructionAction::TOGGLE))->check($action);
v::length(2, 2)->check($coordinatePair);
v::each(v::instance('\\Hamdrew\\AdventOfCode\\Day6\\Coordinate'))->check($coordinatePair);
return new LightInstruction($action, $coordinatePair);
}
示例2: validate_items
protected function validate_items($items)
{
$validator = Validator::instance($this->collection_of());
foreach ($items as $item) {
$this->assert()->is($validator, $item);
}
}
示例3: __construct
public function __construct(array $options)
{
$options = ['baseUri' => Arr::get($options, 'baseUri', $this->baseUri), 'timeout' => Arr::get($options, 'timeout', $this->timeout), 'proxy' => Arr::get($options, 'proxy', $this->proxy), 'auth' => Arr::get($options, 'auth', $this->auth), 'logger' => Arr::get($options, 'logger')];
try {
V::arrayVal()->key('baseUri', V::url()->notEmpty())->key('timeout', V::floatVal()->min(0))->key('proxy', V::optional(V::url()))->key('auth', V::arrayVal()->key('user', V::stringType())->key('pass', V::stringType()))->key('logger', V::instance('\\Psr\\Log\\LoggerInterface'))->assert($options);
} catch (\InvalidArgumentException $e) {
$errors = array_filter($e->findMessages(['baseUri' => 'Required correct baseUri', 'timeout' => 'Required correct timeout', 'proxy' => 'Required correct proxy', 'auth' => 'Required correct authuser', 'logger' => 'Required a logger instance of psr\\log']));
$errmsg = array_shift($errors);
throw new Exception($errmsg);
}
$this->baseUri = $options['baseUri'];
$this->timeout = $options['timeout'];
$this->proxy = $options['proxy'];
$this->auth = $options['auth'];
$this->logger = $options['logger'];
}
示例4: getValidationRules
protected function getValidationRules()
{
v::with('app\\Models\\Validation\\');
return [v::attribute('name', v::notEmpty()->alpha()->length(2, 100)->UniqueDimensionUOMName()), v::attribute('symbol', v::notEmpty()->alpha()->length(2, 2)->UniqueDimensionUOMSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())];
}
示例5: sendBulkMessages
/**
* Send messages in bulk.
*
* @param Message[] $messages
* @param array $params
*
* @return mixed
*/
public function sendBulkMessages(array $messages, array $params = null)
{
$sender = $this->createBulkSender();
v::notEmpty()->setName("BulkSms Array")->check($messages);
foreach ($messages as $message) {
// make sure messages are proper objects
v::instance('anlutro\\BulkSms\\Message')->check($message);
$sender->addMessage($message);
}
if ($params) {
$sender->setParams($params);
}
$response = $sender->send($this->testMode);
$this->validateResponse($response);
return $sender->extractResponse($response);
}
示例6: getValidationRules
protected function getValidationRules()
{
v::with('app\\Models\\Validation\\');
return [v::attribute('provider', v::oneOf(v::instance('app\\Models\\Provider'))), v::attribute('carrier', v::oneOf(v::instance('app\\Models\\Carrier'))), v::attribute('name', v::notEmpty()->length(3, 100)->alpha()->UniqueProviderName()), v::attribute('symbol', v::notEmpty()->length(3, 100)->UniqueProviderSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())];
}
示例7: logDate
/**
*
* @param \DateTime $logDate
* @return boolean
*/
public function logDate($logDate) : bool
{
return V::instance('DateTime')->validate($logDate);
}