本文整理汇总了PHP中Respect\Validation\Validator::floatVal方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::floatVal方法的具体用法?PHP Validator::floatVal怎么用?PHP Validator::floatVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::floatVal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* Handle domain logic for an action.
*
* @param array $input
* @return PayloadInterface
*/
public function __invoke(array $input)
{
//Check that user is authorized to edit this resource
$this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetadata('entity'), 'edit', 'shifts');
//Validate input
$inputValidator = v::key('break', v::floatVal())->key('start_time', v::stringType())->key('end_time', v::stringType())->key('id', v::intVal());
$inputValidator->assert($input);
//Update shift data
$shift = $this->commandBus->handle(new UpdateShiftCommand($input['id'], $input['break'], $input['start_time'], $input['end_time']));
$shiftItem = new Item($shift, new ShiftTransformer());
return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($shiftItem)->toArray());
}
示例2: __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'];
}
示例3: __invoke
/**
* Handle domain logic for an action.
*
* @param array $input
* @return PayloadInterface
*/
public function __invoke(array $input)
{
//Ensure that the use has permission to create shifts
$user = $input[AuthHandler::TOKEN_ATTRIBUTE]->getMetadata('entity');
$this->authorizeUser($user, 'create', 'shifts');
//If no manager_id is specified in request, default to user creating shift
if (!array_key_exists('manager_id', $input)) {
$input['manager_id'] = $user->getId();
}
//Validate input
$inputValidator = v::key('break', v::floatVal())->key('start_time', v::date())->key('end_time', v::date()->min($input['start_time']))->key('manager_id', v::intVal());
$inputValidator->assert($input);
//Execute command to create shift
$shift = $this->commandBus->handle(new CreateShift($input['manager_id'], $input['employee_id'], $input['break'], $input['start_time'], $input['end_time']));
$this->item->setData($shift)->setTransformer($this->shiftTransformer);
return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->parseIncludes(['manager', 'employee'])->createData($this->item)->toArray());
}
示例4: value
public function value($fltValue)
{
if (!Validator::floatVal()->min(0, true)->validate($fltValue)) {
$this->objLogger->addError('Value must be a floating point number');
throw new SMSMessageException('Value must be a floating point number');
}
$this->fltValue = (double) $fltValue;
$this->objLogger->addDebug('Value has been set to ' . $fltValue);
return $this;
}