本文整理汇总了PHP中Validation::notEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::notEmpty方法的具体用法?PHP Validation::notEmpty怎么用?PHP Validation::notEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validation
的用法示例。
在下文中一共展示了Validation::notEmpty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNotEmpty
/**
* testNotEmpty method
*
* @access public
* @return void
*/
function testNotEmpty()
{
$this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertFalse(Validation::notEmpty("\t "));
$this->assertFalse(Validation::notEmpty(""));
}
示例2: arrayNotEmpty
public function arrayNotEmpty($check)
{
$value = current((array) $check);
if (!is_array($value)) {
return Validation::notEmpty($check);
}
return !empty($value);
}
示例3: notBlank
/**
* Custom validation for keeping BC to CakePHP version below 2.7
*
* @param array $check
* @return bool
*/
public function notBlank($check)
{
$value = array_values($check);
$value = $value[0];
if (method_exists('Validation', 'notBlank')) {
return Validation::notBlank($value);
} else {
// below 2.7
return Validation::notEmpty($value);
}
}
示例4: notEmptyForWebApp
public function notEmptyForWebApp($validationFields = array())
{
if (Validation::notEmpty(@$this->data[$this->alias]['type']) && $this->data[$this->alias]['type'] == 'web') {
foreach ($validationFields as $key => $value) {
if (!Validation::notEmpty($value)) {
return false;
}
}
return true;
} else {
return true;
}
}
示例5: testNotEmptyISO88591AppEncoding
/**
* testNotEmptyISO88591Encoding method
*
* @return void
*/
public function testNotEmptyISO88591AppEncoding()
{
Configure::write('App.encoding', 'ISO-8859-1');
$this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
$this->assertTrue(Validation::notEmpty('José'));
$this->assertTrue(Validation::notEmpty(utf8_decode('José')));
$this->assertFalse(Validation::notEmpty("\t "));
$this->assertFalse(Validation::notEmpty(""));
}
示例6: buy
function buy()
{
try {
if ($this->request->is('post')) {
$store = $this->Store->findByStoreHash($this->data['Item']['store_hash']);
if (!$store) {
throw new Exception('Invalid store hash.');
}
$this->Item->id = $this->data['Item']['id'];
$item_is_active = $this->Item->field('is_active');
if (!$item_is_active) {
throw new Exception('Item is sold out.');
}
if (!Validation::email($this->data['Item'][$this->_imap['email']])) {
$this->Item->invalidate($this->_imap['email'], __('Invalid email.'));
}
if (!Validation::notEmpty($this->data['Item']['message'])) {
$this->Item->invalidate('message', __('Cannot be left empty.'));
}
if ($this->Item->validates()) {
if ($this->Item->Save($this->data)) {
$this->Session->setFlash('Item purchased.', 'default', array('class' => 'message success'));
$message = array('Message' => array('store_id' => $store['Store']['id'], 'item_id' => $this->Item->id, 'sender_email' => $this->data['Item'][$this->_imap['email']], 'receiver_email' => $store['Store']['email'], 'body' => $this->data['Item']['message']));
if ($this->_logged_user) {
$message['Message']['sender_id'] = $this->_logged_user['id'];
$message['Message']['sender_email'] = $this->_logged_user['email'];
}
if (isset($store['Store']['user_id'])) {
$message['Message']['receiver_id'] = $store['Store']['user_id'];
}
if ($this->Message->save($message)) {
$subject = 'Someone bought your item';
$this->Email->send($message['Message']['sender_email'], $store['Store']['email'], $subject, $this->data['Item']['message']);
}
}
}
$this->_processIframeForm($this->Item->validationErrors, $this->data, $this->referer());
}
} catch (Exception $e) {
$this->Session->setFlash($e->getMessage(), 'default', array('class' => 'message error'));
$this->redirect($this->referer());
exit;
}
}
示例7: testInvalidNotEmptyWithSpaces
/**
* @testdox notEmpty should return false to blank space string
*/
public function testInvalidNotEmptyWithSpaces()
{
$value = ' ';
$this->assertFalse(Validation::notEmpty($value));
}
示例8: add
function add()
{
global $G;
require CLASS_PATH . "validation.class.php";
$validate = new Validation();
uses("trade", "member", "tradefield", "tag");
$tag = new Tags();
$offer = $tradefield = new Tradefields();
$member = new Members();
$trade = new Trades();
if (isset($_POST['visit_post'])) {
capt_check("capt_post_free");
pb_submit_check('visit_post');
$_POST['data']['trade']['title'] = pb_lang_merge($_POST['data']['multi']);
$trade->setParams();
$tradefield->setParams();
$if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']);
if (!empty($if_title_exists)) {
$trade->validationErrors[] = L("semilar_offer_post");
}
if (!$validate->notEmpty($trade->params['data']['trade']['title'])) {
$trade->validationErrors[] = L("title_cant_be_empty");
}
$trade->params['expire_days'] = $_POST['expire_days'];
$if_check = $G['setting']['vis_post_check'];
$msg = null;
$words = $trade->dbstuff->GetArray("SELECT * FROM {$trade->table_prefix}words");
if (!empty($words)) {
foreach ($words as $word_val) {
if (!empty($word_val['title'])) {
str_replace($word_val['title'], "***", $trade->params['data']['trade']['title']);
str_replace($word_val['title'], "***", $trade->params['data']['trade']['content']);
}
}
$item['forbid_word'] = implode("\r\n", $tmp_str);
}
if ($if_check) {
$trade->params['data']['trade']['status'] = 0;
$msg = 'pls_wait_for_check';
} else {
$trade->params['data']['trade']['status'] = 1;
$msg = 'success';
}
if (!empty($trade->validationErrors)) {
setvar("item", am($trade->params['data']['trade'], $tradefield->params['data']['tradefield']));
setvar("Errors", $validate->show($trade));
render("offer/post");
} else {
$trade->params['data']['trade']['industry_id'] = implode(",", $_POST['industry']['id']);
$trade->params['data']['trade']['area_id'] = implode(",", $_POST['area']['id']);
$result = $trade->Add();
if ($result) {
flash($msg);
} else {
flash();
}
}
}
}
示例9: notBlank
/**
* Shim wrapper for 2.6 to allow 2.7 notBlank validation rule to work already.
* This is only there to avoid the deprecation errors in 2.6 test runs.
*
* @param array $data
* @return bool
*/
public function notBlank($data)
{
$value = array_shift($data);
if ((double) Configure::version() < 2.7) {
return Validation::notEmpty($value);
}
return Validation::notBlank($value);
}
示例10: L
setvar("PhoneTypes", $typeoption->get_cache_type("phone_type"));
setvar("ImTypes", $typeoption->get_cache_type("im_type"));
$if_visit_post = $_PB_CACHE['setting']['vis_post'];
if (!$if_visit_post) {
$smarty->flash('visitor_forbid', URL, 0);
}
capt_check("capt_post_free");
if (isset($_POST['visit_post'])) {
pb_submit_check('visit_post');
$trade->setParams();
$tradefield->setParams();
$if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']);
if (!empty($if_title_exists)) {
$trade->validationErrors[] = L("semilar_offer_post");
}
if (!$validate->notEmpty($trade->params['data']['trade']['title'])) {
$trade->validationErrors[] = L("title_cant_be_empty");
}
$trade->params['expire_days'] = $_POST['expire_days'];
//$trade->params['data']['trade']['tag_ids'] = $tag->setTagId($_POST['data']['tag']);;
$if_check = $_PB_CACHE['setting']['vis_post_check'];
$msg = null;
$words = $pdb->GetArray("SELECT * FROM {$tb_prefix}words");
if (!empty($words)) {
foreach ($words as $word_val) {
if (!empty($word_val['title'])) {
str_replace($word_val['title'], "***", $trade->params['data']['trade']['title']);
str_replace($word_val['title'], "***", $trade->params['data']['trade']['content']);
}
}
$item['forbid_word'] = implode("\r\n", $tmp_str);
示例11: formatJson
/**
* formatJson
* jpn: json形式の文字列かどうか
*
*/
public function formatJson(Model $model, $field)
{
$value = array_shift($field);
if (!Validation::notEmpty($value)) {
return true;
}
$result = json_decode($value);
if ($result === null) {
return false;
}
return true;
}