本文整理汇总了PHP中Validation::Factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::Factory方法的具体用法?PHP Validation::Factory怎么用?PHP Validation::Factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validation
的用法示例。
在下文中一共展示了Validation::Factory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_post
/**
* Create a new post and recalculate post count.
*
* @param array $values
* @param array $expected
* @return ORM
*/
public function create_post($values, $expected)
{
// Validation for topic
$extra_validation = Validation::Factory($values)->rule('topic_id', 'Model_Forum_Topic::topic_exists');
$this->values($values, $expected)->create($extra_validation);
// Update the post count for the post owner.
$user = $this->user;
$user->set_property('forum.posts', $user->get_property('forum.posts') + 1);
$user->save();
return $this;
}
示例2: create_vote
public function create_vote($values, $expected)
{
// Validation for vote
$extra_validation = Validation::Factory($values)->rule('poll_id', 'Model_Forum_Poll::poll_exists')->rule('option_id', 'Model_Forum_Poll_Option::option_exists');
return $this->values($values, $expected)->create($extra_validation);
}
示例3: create_poll
public function create_poll($values, $expected)
{
// Validation for poll
$extra_validation = Validation::Factory($values)->rule('topic_id', 'Model_Forum_Topic::topic_exists');
return $this->values($values, $expected)->create($extra_validation);
}
示例4: create_message
public function create_message($values, $expected)
{
// Validation for id
$extra_validation = Validation::Factory($values)->rule('receiver_id', 'Model_User::user_exists');
return $this->values($values, $expected)->create($extra_validation);
}
示例5: validateEmailOrPhone
private function validateEmailOrPhone($post)
{
$extra_validation = Validation::Factory($post);
if (empty($post['phone'])) {
$extra_validation->rule('email', 'not_empty');
} else {
if (empty($post['email'])) {
$extra_validation->rule('phone', 'not_empty');
}
}
return $extra_validation;
}
示例6: build_regID
public function build_regID($post, $locations, $convention_id)
{
$validate = Validation::Factory($post)->rule('comp_loc', 'in_array', array(':value', array_values($locations)))->rule('comp_id', 'numeric')->rule('comp_id', 'not_empty');
$errors = array();
if (!$validate->check() || !is_numeric($convention_id)) {
foreach ($validate->errors('reg_id') as $error_msg) {
array_push($errors, $error_msg);
}
$this->reg_id = '';
} else {
$this->reg_id = sprintf('%s-%02s-%04s', $post['comp_loc'], $convention_id, $post['comp_id']);
}
return $errors;
}
示例7: create_pet
public function create_pet($values, $expected)
{
$extra_validation = Validation::Factory($values)->rule('colour_id', 'Valid_Pet::colour_free', array(':value'));
return $this->values($values, $expected)->create($extra_validation);
}
示例8: action_changePassword
function action_changePassword()
{
/* Set page title */
$this->template->title = __('Change Password');
$this->template->heading = __('Change Your Password');
$this->template->subheading = __('Change your account password.');
/* Require login */
$this->requireLogin();
/* Get logged in account */
$account = $this->auth->getAccount();
$fields = $account->default_fields;
$form = array('password' => '', 'confirm_password' => '');
$errors = $form;
if ($post = $this->request->post()) {
$extra_validation = Validation::Factory($post);
$account->values($post);
try {
$extra_validation->rule('password', 'matches', array(':validation', 'password', 'confirm_password'));
$account->save($extra_validation);
$this->addMessage('Successfully changed the password for ' . $account->email);
/* Complete login, update hash, update timestamps, etc */
$account->salt = null;
$account->password = $post['password'];
$this->auth->complete_login($account);
$this->request->redirect('user/index');
return;
} catch (ORM_Validation_Exception $e) {
// repopulate the form fields
$form = arr::overwrite($form, $post);
// populate the error fields, if any
// We need to already have created an error message file, for Kohana to use
// Pass the error message file name to the errors() method
$error_list = $e->errors('form_error_messages');
$errors = arr::overwrite($errors, $error_list);
if (!empty($error_list['_external']['password'])) {
$errors['confirm_password'] = $error_list['_external']['password'];
//This is a hack!
}
} catch (Exception $e) {
$this->addError("Oops. Something went wrong and it's not your fault. Contact the system maintainer please!");
}
}
$this->template->content = new View('user/changePassword', array('form' => $form, 'errors' => $errors, 'fields' => $fields));
}