本文整理汇总了PHP中validator类的典型用法代码示例。如果您正苦于以下问题:PHP validator类的具体用法?PHP validator怎么用?PHP validator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了validator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($file = '', $rule = '', $encode = 'utf8', $VAL = null)
{
q4mController::useHelper('validator');
if ($file == '') {
$file = str_replace('Model', '', get_class($this)) . 'Rules.php';
}
if ($rule == '') {
$rule = str_replace('Model', '', get_class($this));
}
if (file_exists(_SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php')) {
include_once _SETTINGS_DIR_ . $file . 'Rules.php';
if (!isset(${$rule}) || !count(${$rule})) {
q4mSystem::haltOnError('The requested rule "' . ${$rule} . '" is empty in ', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
exit;
}
} else {
q4mSystem::haltOnError('The file is not found', _SYS_DIR_ . _SETTINGS_DIR_ . $file . 'Rules.php', __FILE__, __LINE__);
exit;
}
$rules = ${$rule};
$vc = new validator($rules, $encode, $VAL);
if (count($vc->RULES)) {
foreach ($vc->RULES as $key => $SV) {
$vc->validate($key);
}
}
if (count($vc->ERRORS)) {
return $vc->ERRORS;
} else {
return false;
}
}
示例2: registerUser
public static function registerUser()
{
$sql = sql::factory();
$sql->setTable('community_user');
$sql->getPosts(['username' => 'string', 'password' => 'string', 'email' => 'string']);
$validator = new validator();
$email = $sql->getPost('email');
$username = $sql->getPost('username');
$password = $sql->getPost('password');
$validUsername = $validator->costum($username, function () {
preg_match('/\\w{4,}/', $username, $match);
return $match[0] == $username;
});
if (!$validUsername) {
return 'Username darf nur aus Buchstaben Zahlen und Unterstrich bestehen und muss mindestens 4 Zeichen lang sein.';
}
if ($sql->num('SELECT id FROM ' . sql::table('community_user') . ' WHERE `username`= "' . $sql->escape($username) . '"')) {
return 'Benutzername schon vorhanden';
}
if (!$validator->email($email)) {
return 'Bitte geben Sie eine E-Mail Adresse an';
}
$salt = userLogin::generateSalt();
$sql->addDatePost('registerdate', 'now');
$sql->addPost('salt', $salt);
extension::get('COMMUNITY_USER_REGISTER', $sql);
$password = userLogin::hash($password, $salt);
$sql->addPost('password', $password);
$sql->save();
//Mail send
return true;
}
示例3: execute
public function execute()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$validator = new validator($this->output);
if ($validator->execute($this->pattern)) {
$this->output->add_system_message("Data validation oke.");
}
}
$this->output->record($_POST);
}
示例4: init
protected static function init()
{
if (!self::$has_init) {
spl_autoload_register(array('validator', 'autoloader'), FALSE, TRUE);
self::$has_init = TRUE;
}
}
示例5: validatelogin
function validatelogin($login = null)
{
$this->login = $login;
$this->min = 6;
$this->max = 20;
validator::validator();
}
示例6: getFails
/**
* エラー対象リソースの配列を取得
*
* @return Array
*/
public function getFails()
{
if (!isset($this->validator)) {
throw new \Exception('validator not found.');
}
return $this->validator->failed();
}
示例7: validateblogurl
function validateblogurl($blogurl = null)
{
$this->blogurl = $blogurl;
$this->min = 6;
$this->max = 50;
validator::validator();
}
示例8: validatesecretanswer
function validatesecretanswer($answer = null)
{
$this->answer = $answer;
$this->min = 6;
$this->max = 60;
validator::validator();
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$url = $request->input('url');
//验证提交的url
$target = ['url' => $url];
$roule = ['url' => 'required|url'];
$message = ['url' => $url . '不是合法的url', 'required' => '请求输入url'];
$validator = validator::make($target, $roule, $message);
if ($validator->fails()) {
return redirect('url')->withErrors($validator);
}
//检测在数据库
$result = Url::where('url', $url)->first();
//dd($result);
if ($result) {
return view('url.result')->with('short_url', $result->short_url);
}
//检测不在数据库
$short_url = Url::get_short_url();
$res = Url::insert(['url' => $url, 'short_url' => $short_url]);
if ($res) {
return view('url.result')->with('short_url', $short_url);
} else {
return '数据添加失败';
}
}
示例10: validatedbname
function validatedbname($dbname = null)
{
$this->dbname = $dbname;
$this->min = 6;
$this->max = 64;
validator::validator();
}
示例11: validatedbpasswd
function validatedbpasswd($dbpasswd = null)
{
$this->dbpasswd = $dbpasswd;
$this->min = 6;
$this->max = 20;
validator::validator();
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user_id = Auth::User()->id;
if (Input::file()) {
$file_image = array('image' => Input::file('file_image'));
$rules = array('image' => 'required');
$validator = validator::make($file_image, $rules);
if ($validator->fails()) {
return redirect::to('photo')->withInput()->withErrors($validator);
} else {
if (Input::file('file_image')->isValid()) {
$path = '../public/images';
$extension = Input::file('file_image')->getClientOriginalExtension();
$fileName = rand() . '.' . $extension;
Input::file('file_image')->move($path, $fileName);
Image::create(array('user_id' => $user_id, 'path' => $fileName));
Session::flash('success', 'Upload successfully');
return Redirect::to('photo');
} else {
Session::flash('error', 'uploaded file is not valid');
return Redirect::to('photo');
}
}
}
}
示例13: validateauthorname
function validateauthorname($aname = null)
{
$this->aname = $aname;
$this->min = 4;
$this->max = 50;
validator::validator();
}
示例14: validatedbuser
function validatedbuser($dbuser = null)
{
$this->dbuser = $dbuser;
$this->min = 6;
$this->max = 16;
validator::validator();
}
示例15: action_index
function action_index()
{
if (isset($_POST['submit'])) {
$validator = new validator();
$data["errors"]["login"] = $validator->is_correct_login($_POST['login']) ? "" : "has-error";
$data["errors"]["pass"] = $validator->is_correct_pass($_POST['password']) ? "" : "has-error";
if ($this->model->approveUser($_POST['login'], $_POST['password']) && $validator->result) {
header("Location: /main");
} else {
$data["errors"]["login"] = "has-error";
$data["errors"]["pass"] = "has-error";
}
}
$data["login"] = $this->model->get_login();
$this->view->generate('login_view.php', 'template_view.php', $data);
}