本文整理匯總了PHP中Respect\Validation\Validator::noWhitespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::noWhitespace方法的具體用法?PHP Validator::noWhitespace怎麽用?PHP Validator::noWhitespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::noWhitespace方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postChangePassword
public function postChangePassword($request, $response)
{
$validation = $this->validator->validate($request, ['password_old' => v::noWhitespace()->notEmpty()->matchesPassword($this->auth->user()->password), 'password' => v::noWhitespace()->notEmpty()]);
if ($validation->failed()) {
return $response->withRedirect($this->router->pathFor('auth.password.change'));
}
$this->auth->user()->setPassword($request->getParam('password'));
$this->flash->addMessage('info', 'Your password was changed');
return $response->withRedirect($this->router->pathFor('home'));
}
示例2: postSignUp
public function postSignUp($request, $response)
{
$validation = $this->validator->validate($request, ['email' => v::noWhitespace()->notEmpty()->email()->emailAvailable(), 'name' => v::noWhitespace()->notEmpty()->alpha(), 'password' => v::noWhitespace()->notEmpty()]);
if ($validation->failed()) {
return $response->withRedirect($this->router->pathFor('auth.signup'));
}
$user = User::create(['email' => $request->getParam('email'), 'name' => $request->getParam('name'), 'password' => password_hash($request->getParam('password'), PASSWORD_DEFAULT)]);
$this->flash->addMessage('info', 'You have been signed up');
$this->auth->attempt($user->email, $request->getParam('password'));
return $response->withRedirect($this->router->pathFor('home'));
}
示例3: isValidPassword
public static function isValidPassword($password)
{
return v::noWhitespace()->length(8)->validate($password);
}
示例4: validateServer
/**
* @brief Validate the server
*
* @param string $server
*/
private function validateServer($server)
{
$validate_server = Validator::noWhitespace()->alnum('.-_')->length(6, 40);
return $validate_server->validate($server);
}
示例5:
if (!empty($_POST)) {
//If the Post is not empty, it means that it is an insert from the add form
$userNameError = null;
$passwordError = null;
$unidadeError = null;
$nameError = null;
$emailError = null;
//getting POST data
$userName = $_POST[username];
$password = $_POST[password];
$unidade = $_POST[unidade];
$name = $_POST[name];
$email = $_POST[email];
//Validation using respect/validation
$valid = true;
if (!v::noWhitespace()->length(4, 20)->notEmpty()->validate($userName)) {
$userNameError = "Por favor digite novamente o nome de usuário, entre 4 e 20 caracteres, sem espaços em branco";
$valid = false;
}
if (!v::notEmpty()->validate($password)) {
$passwordError = "Por favor digite a senha não pode ficar em branco";
$valid = false;
}
if (!v::notEmpty()->length(1, 5)->validate($unidade)) {
$unidadeError = "Por favor digite novamente o unidade, no formato A-00 (letra, traço e número)";
$valid = false;
}
if (!v::length(3, 80)->notEmpty()->validate($name)) {
$nameError = "Por favor digite novamente o nome do morador, entre 3 e 80 caracteres";
$valid = false;
}
示例6: PostChangePassword
public function PostChangePassword($request, $response)
{
// matchesPassword() is a custom validation rule, see Classes/Validation
// using $this->container->auth->user() as its parameter is a
// preparation for cases when user's password can be reset by an admin
// as well (not only the user himselft)
$validation = $this->container->validator->validate($request, ['password_old' => v::noWhitespace()->notEmpty()->matchesPassword($this->container, $this->container->auth->user()), 'password' => v::noWhitespace()->notEmpty()]);
// on validation failure redirect back to the form. the rest of this
// function won't get exectuted
if ($validation->failed()) {
return $response->withRedirect($this->container->router->pathFor('auth.password.change'));
}
// change the password, emit flash message and redirect
// TODO error handling on failed db->update
$user_id = $_SESSION['user'] ?? false;
if ($user_id) {
$password = $request->getParam('password');
$this->container->db->where('id', $user_id);
$this->container->db->update('users', array('password' => password_hash($password, PASSWORD_DEFAULT)));
$this->container->flash->addMessage('info', 'Your password was changed');
return $response->withRedirect($this->container->router->pathFor('home'));
}
}
示例7: validNowhitespace
/**
* Verifica se o valor não possui espaços, quebras de linha e tabs
* @param string $value
* @return boolean
*/
public function validNowhitespace($value)
{
if (!v::noWhitespace()->validate($value)) {
Factory::log()->warn('Valor não pode possuir espaços e quebras de linha');
return false;
}
return true;
}