本文整理汇总了PHP中Respect\Validation\Validator::intVal方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::intVal方法的具体用法?PHP Validator::intVal怎么用?PHP Validator::intVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::intVal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidatorWithFilterGroups
public function testValidatorWithFilterGroups()
{
$allOfFilter = new AllOfFilter([new ClosureFilter('name', v::intVal()), v::key('key', v::regex('/test.+/i'))]);
static::assertTrue($allOfFilter->matches(['name' => '1234', 'key' => 'test47382']));
static::assertFalse($allOfFilter->matches(['name' => 'test', 'key' => 'test47382']));
static::assertFalse($allOfFilter->matches(['name' => '1234', 'key' => 'test']));
}
示例2: initRule
/**
* init valid rule
*/
protected function initRule()
{
$this->validRule['id'] = v::numeric();
$this->validRule['name'] = v::stringType()->length(1, 10);
$this->validRule['email'] = v::email();
$this->validRule['sex'] = v::intVal()->between(0, 1);
}
示例3: validateLevel
protected function validateLevel()
{
$value = v::intVal()->notEmpty()->validate($this->getLevel());
if (!$value) {
msg::showMsg('O campo Nível de Acesso deve ser deve ser preenchido corretamente.' . '<script>focusOn("level");</script>', 'danger');
}
return $this;
}
示例4: deleteUser
static function deleteUser($app, $userId)
{
if (!v::intVal()->validate($userId)) {
return $app->render(400, array('msg' => 'Could not find user. Check your parameters and try again.'));
}
if (UserData::deleteUser($userId)) {
return $app->render(200, array('msg' => 'User has been deleted.'));
} else {
return $app->render(400, array('msg' => 'Could not delete user.'));
}
}
示例5: __invoke
/**
* Handle domain logic for an action.
*
* @param array $input
* @return PayloadInterface
*/
public function __invoke(array $input)
{
//Check that user has permission to edit this resource
$this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetaData('entity'), 'edit', 'shifts');
//Validate input
$inputValidator = v::key('id', v::intVal())->key('employee_id', v::intVal());
$inputValidator->assert($input);
//Execute command to update employee on shift
$shift = $this->commandBus->handle(new AssignShiftCommand($input['id'], $input['employee_id']));
$shiftItem = new Item($shift, new ShiftTransformer());
return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->parseIncludes(['manager', 'employee'])->createData($shiftItem)->toArray());
}
示例6: deleteRole
static function deleteRole($app, $roleId)
{
if (!v::intVal()->validate($roleId)) {
return $app->render(400, array('msg' => 'Could not delete role. Check your parameters and try again.'));
} else {
if (RoleData::deleteRole($roleId)) {
return $app->render(200, array('msg' => 'Role has been deleted.'));
} else {
return $app->render(400, array('msg' => 'Could not delete role.'));
}
}
}
示例7: __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());
}
示例8: __invoke
/**
* Handle domain logic for an action.
*
* @param array $input
* @return PayloadInterface
*/
public function __invoke(array $input)
{
//Check that user is authorized to view this resource
$this->authorizeUser($input[AuthHandler::TOKEN_ATTRIBUTE]->getMetadata('entity'), 'view', 'users');
//Validate input
$inputValidator = v::key('id', v::intVal());
$inputValidator->assert($input);
//Get user from repository and transform into resource
$user = $this->userRepository->getOneByIdOrFail($input['id']);
$this->item->setData($user)->setTransformer($this->userTransformer);
return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->createData($this->item)->toArray());
}
示例9: deleteGroup
static function deleteGroup($app, $groupId)
{
if (!v::intVal()->validate($groupId)) {
return $app->render(400, array('msg' => 'Could not delete group. Check your parameters and try again.'));
} else {
if (GroupData::deleteGroup($groupId)) {
return $app->render(200, array('msg' => 'Group has been deleted.'));
} else {
return $app->render(400, array('msg' => 'Could not delete group.'));
}
}
}
示例10: initRule
/**
* init valid rule
*/
protected function initRule()
{
$this->validRule['uid'] = v::numeric();
$this->validRule['eduid'] = v::numeric();
$this->validRule['schoolName'] = v::stringType()->length(1, 32);
$this->validRule['majorName'] = v::stringType()->length(1, 32);
$this->validRule['majorCat'] = v::stringType()->length(1, 32);
$this->validRule['area'] = v::stringType()->length(1, 32);
$this->validRule['schoolCountry'] = v::stringType()->length(1, 32);
$this->validRule['startDate'] = v::date('Y-m');
$this->validRule['endDate'] = v::date('Y-m');
$this->validRule['degreeStatus'] = v::intVal()->between(1, 3);
}
示例11: __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());
}
示例12: __invoke
/**
* @param array $input
* @return PayloadInterface
* @throws UserNotAuthorized
*/
public function __invoke(array $input)
{
//Don't allow employees to view other employee's shifts
//todo: figure out if managers can access all employees' shifts
if ($input['id'] != $input[AuthHandler::TOKEN_ATTRIBUTE]->getMetaData('id')) {
throw new UserNotAuthorized();
}
//Validate input
$inputValidator = v::key('id', v::intVal());
$inputValidator->assert($input);
//Get shifts and transform
$employee = $this->userRepository->getOneByIdOrFail($input['id']);
$shifts = $this->shiftRepository->getByEmployee($employee);
$this->collection->setData($shifts)->setTransformer($this->shiftTransformer);
$include = array_key_exists('include', $input) ? $input['include'] : '';
return $this->payload->withStatus(PayloadInterface::OK)->withOutput($this->fractal->parseIncludes($include)->createData($this->collection)->toArray());
}
示例13: deleteVariable
static function deleteVariable($app, $variableId)
{
if (!v::intVal()->validate($variableId)) {
return $app->render(400, array('msg' => 'Could not find system config variable.'));
}
$savedConfig = ConfigData::getVariableById($variableId);
if ($savedConfig && ($savedConfig->locked || $savedConfig->indestructible)) {
return $app->render(400, array('msg' => 'This config variable is locked or indestructible and cannot deleted without special permissions.'));
}
if (ConfigData::deleteVariable($variableId)) {
return $app->render(200, array('msg' => 'System config variable has been deleted.'));
} else {
return $app->render(400, array('msg' => 'Could not delete system config variable. Check your parameters and try again.'));
}
}
示例14: ContainerBuilder
use DI\ContainerBuilder;
use Respect\Validation\Validator;
require __DIR__ . '/bootstrap.php';
$builder = new ContainerBuilder();
$container = $builder->buildDevContainer();
$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];
$minDay = 1;
$maxDay = 25;
if ($argc > 2) {
error_log('Usage: php SolutionRunner.php [day]');
exit(1);
}
if ($argc == 2) {
$day = intval($argv[1]);
if (!Validator::intVal()->between($minDay, $maxDay)->validate($day)) {
error_log("Day must be between {$minDay} and {$maxDay}");
exit(1);
}
$minDay = $day;
$maxDay = $day;
}
for ($i = $minDay; $i <= $maxDay; $i++) {
echo "Running solution for Day {$i}...\n";
/** @var Solution $class */
$class = "\\Hamdrew\\AdventOfCode\\Day{$i}\\SolutionDay{$i}";
if (!class_exists($class)) {
echo "WARNING: Solution for day {$i} not found\n";
return;
}
$part1 = $container->get($class)->part1();
示例15: providerForInvalidNot
public function providerForInvalidNot()
{
return [[new IntVal(), 123], [new AllOf(new OneOf(new Numeric(), new IntVal())), 13.37], [new OneOf(new Numeric(), new IntVal()), 13.37], [Validator::oneOf(Validator::numeric(), Validator::intVal()), 13.37]];
}