本文整理汇总了PHP中validator类的典型用法代码示例。如果您正苦于以下问题:PHP validator类的具体用法?PHP validator怎么用?PHP validator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了validator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:spraynakama,项目名称:q4m_framework,代码行数:32,代码来源:class.q4mModel.php
示例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;
}
开发者ID:pasterntt,项目名称:dynao-CMS,代码行数:32,代码来源:community_register.php
示例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);
}
开发者ID:shannara,项目名称:banshee,代码行数:10,代码来源:validation.php
示例4: init
protected static function init()
{
if (!self::$has_init) {
spl_autoload_register(array('validator', 'autoloader'), FALSE, TRUE);
self::$has_init = TRUE;
}
}
开发者ID:SwayWebStudio,项目名称:night.com,代码行数:7,代码来源:class.validator.php
示例5: validatelogin
function validatelogin($login = null)
{
$this->login = $login;
$this->min = 6;
$this->max = 20;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatelogin.class.php
示例6: getFails
/**
* エラー対象リソースの配列を取得
*
* @return Array
*/
public function getFails()
{
if (!isset($this->validator)) {
throw new \Exception('validator not found.');
}
return $this->validator->failed();
}
开发者ID:hoshiko-dev,项目名称:moderate-framework,代码行数:12,代码来源:MfBaseValidation.php
示例7: validateblogurl
function validateblogurl($blogurl = null)
{
$this->blogurl = $blogurl;
$this->min = 6;
$this->max = 50;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validateblogurl.class.php
示例8: validatesecretanswer
function validatesecretanswer($answer = null)
{
$this->answer = $answer;
$this->min = 6;
$this->max = 60;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatesecretanswer.class.php
示例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 '数据添加失败';
}
}
开发者ID:jew977,项目名称:laravel5_unique_short_url-,代码行数:31,代码来源:UrlController.php
示例10: validatedbname
function validatedbname($dbname = null)
{
$this->dbname = $dbname;
$this->min = 6;
$this->max = 64;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatedbname.class.php
示例11: validatedbpasswd
function validatedbpasswd($dbpasswd = null)
{
$this->dbpasswd = $dbpasswd;
$this->min = 6;
$this->max = 20;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatedbpasswd.class.php
示例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');
}
}
}
}
开发者ID:GrigorAtaryan,项目名称:Social_network,代码行数:31,代码来源:ImageController.php
示例13: validateauthorname
function validateauthorname($aname = null)
{
$this->aname = $aname;
$this->min = 4;
$this->max = 50;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validateauthorname.class.php
示例14: validatedbuser
function validatedbuser($dbuser = null)
{
$this->dbuser = $dbuser;
$this->min = 6;
$this->max = 16;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatedbuser.class.php
示例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);
}
开发者ID:Kinqston,项目名称:MasterClass,代码行数:16,代码来源:controller_login.php
示例16: TambahJadwal
public function TambahJadwal()
{
$rules = array('unit_id' => 'required', 'kategori' => 'required', 'tglstart' => 'required', 'tglases' => 'required', 'tglfinish' => 'required', 'detail' => 'required');
$messages = array('unit_id.required' => 'Nama Jabatan Harus Terisi', 'kategori.required' => 'Kategori Harus Dipilih', 'tglstart.required' => 'Tanggal Mulai Harus Terisi', 'tglases.required' => 'Tanggal Asessment Harus Terisi', 'tglfinish.required' => 'Tanggal Selesai Harus Terisi', 'detail.required' => 'Detail Harus terisi');
$validasi = validator::make(Input::all(), $rules, $messages);
if ($validasi->fails()) {
return Redirect::back()->withErrors($validasi)->withInput();
} else {
$kat = Input::get('kategori');
if ($kat == 'internal') {
$aa = "in";
} else {
$aa = "ex";
}
DB::transaction(function ($aa) use($aa) {
//asesment promosi
$jadwal = KandidatPromote::create(['unit_staf_id' => Input::get('unit_id'), 'tgl_awal' => Input::get('tglstart'), 'tgl_asesment' => Input::get('tglases'), 'tgl_selesai' => Input::get('tglfinish'), 'detail' => Input::get('detail')]);
//rekrutmen rekap header
$rekap_header = HeaderRekap::create(['id_asesmen' => $jadwal->id, 'kategori' => Input::get('kategori'), 'nama' => Input::get('jabatan'), 'tanggal_awal' => Input::get('tglstart'), 'tanggal_akhir' => Input::get('tglfinish'), 'deksripsi' => Input::get('detail')]);
//asessment promosi daftar
$daftar = KandidatPromosiDaftar::create(['asesment_promosi_id' => $jadwal->id, 'nip' => Input::get('nip'), 'detail' => Input::get('detail')]);
//rekrutment rekap profiling
$profil = ProfilingRekap::create(['id_rekap' => $rekap_header->id, 'kategori' => $aa, 'nip' => $daftar->nip, 'id_jabatan' => $jadwal->unit_staf_id]);
});
Session::flash('message', 'Berhasil Menambahkan Jadwal Asessment');
return Redirect::to('career/jadwal/lihat/asessment');
}
}
开发者ID:hendrilara,项目名称:kemenpan,代码行数:28,代码来源:KandidatPromosiController.php
示例17: validateInput
public static function validateInput($data)
{
//print_r($data);
$data = array_map(array('validator', 'utf8_decode'), $data);
$data = array_map(array('validator', 'get_magic_quotes_gpc'), $data);
$data = array_map(array('validator', 'strip_tags'), $data);
$data = array_map(array('validator', 'my_htmlspecialchars'), $data);
// if (get_magic_quotes_gpc()){
// $data=array_map(array('validator','stripslashes'),$data);
// }
// $data=array_map(array('validator','strip_tags'),$data);
// $data=array_map(array('validator','htmlspecialchars'),$data);
foreach (self::$dictionaryList as $table) {
$DataDictionary = 'dataDictionary_' . $table;
$dataDic = new $DataDictionary();
$fieldSpec = $dataDic->fieldSpec;
foreach ($data as $key => $value) {
if (isset($fieldSpec[$key])) {
self::fieldValidation($key, $value, $fieldSpec[$key]);
self::$completed[trim($key)] = trim($value);
}
//if
}
//foreach
}
//forach
self::$cleanData = self::$completed;
//do the swap here so we can handle default data
self::$completed = '';
}
开发者ID:Git-Host,项目名称:sms,代码行数:30,代码来源:validator.class.php
示例18: set_class_col
function set_class_col($col, $val = '')
{
if (!isset($col) || empty($col)) {
return false;
}
$validator = new validator();
$isValid = $validator->check_value($col, $val, $col, "string", 0, 255);
if ($isValid) {
$this->{$col} = $val;
} else {
foreach ($validator->error_list as $key => $data) {
$this->set_message($validator->error_list[$key]["msg"]);
}
}
return $isValid;
}
开发者ID:CDESmith,项目名称:newtwo,代码行数:16,代码来源:class.generic_object.php
示例19: save
public function save()
{
$post = input::get();
$ruledata = $post['ruledata'];
$H = $post['_DTIME_']['H'];
$M = $post['_DTIME_']['M'];
foreach ($H as $key => $val) {
$ruledata[$key] = strtotime($post[$key] . " " . $val . ":" . $M[$key]);
}
$validator = validator::make(array('0' => $ruledata['buy_limit'], '1' => $ruledata['discount_min'], '2' => $ruledata['discount_max'], '3' => date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '4' => date('Y-m-d H:i:s', $ruledata['apply_end_time']), '5' => date('Y-m-d H:i:s', $ruledata['release_time']), '6' => date('Y-m-d H:i:s', $ruledata['start_time']), '7' => date('Y-m-d H:i:s', $ruledata['end_time']), '8' => $ruledata['shoptype'], '9' => $ruledata['limit_cat'], '10' => $ruledata['activity_name'], '11' => $ruledata['activity_tag']), array('0' => 'min:0', '1' => 'numeric|min:0.01|max:99.99', '2' => 'numeric|max:99.99|min:' . $ruledata['discount_min'], '3' => 'after:' . date('Y-m-d H:i:s', time()), '4' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '5' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_end_time']), '6' => 'after:' . date('Y-m-d H:i:s', $ruledata['release_time']), '7' => 'after:' . date('Y-m-d H:i:s', $ruledata['start_time']), '8' => 'required', '9' => 'required', '10' => 'required|max:20', '11' => 'required|max:10'), array('0' => '用户限购数量要大于0!', '1' => '折扣必须是数字|折扣范围必须大于0|折扣范围必须小于100', '2' => '折扣必须是数字|折扣范围必须小于100|折扣范围必须由小到大!', '3' => '活动报名的开始时间必须大于当前时间!', '4' => '活动报名结束时间必须大于报名的开始时间!', '5' => '发布时间必须大于报名结束时间!', '6' => '活动生效时间必须大于活动发布时间!', '7' => '活动生效结束时间必须大于活动开始时间!', '8' => '至少选择一种店铺类型!', '9' => '至少选择一种平台商品类目!', '10' => '|活动名称长度必须小于20', '11' => '|活动标签长度必须小于10'));
if ($validator->fails()) {
$messages = $validator->messagesInfo();
foreach ($messages as $error) {
return $this->splash('error', null, $error[0]);
}
}
$this->begin("?app=syspromotion&ctl=admin_activity&act=index");
try {
kernel::single('syspromotion_activity')->saveActivity($ruledata);
$this->adminlog("添加活动{$post['activity_name']}", 1);
} catch (Exception $e) {
$this->adminlog("添加活动{$post['activity_name']}", 0);
$msg = $e->getMessage();
$this->end(false, $msg);
}
$this->end(true);
}
开发者ID:453111208,项目名称:bbc,代码行数:27,代码来源:activity.php
示例20: validatedbhost
function validatedbhost($dbhost = null)
{
$this->dbhost = $dbhost;
$this->min = 6;
$this->max = 20;
validator::validator();
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:7,代码来源:validatedbhost.class.php
注:本文中的validator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论